~ chicken-core (chicken-5) 004f21c32cc3374c9a342a693b4192b82fa37df9
commit 004f21c32cc3374c9a342a693b4192b82fa37df9 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Tue Jan 5 13:17:48 2010 +0100 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Tue Jan 5 13:17:48 2010 +0100 fixed bug in unused-var-removal optimization done the other day diff --git a/optimizer.scm b/optimizer.scm index 8a7320e2..150246ea 100644 --- a/optimizer.scm +++ b/optimizer.scm @@ -68,7 +68,8 @@ (let ((var (first params))) (when (and (not (memq var e)) (not (memq var safe))) - (set! unsafe (cons var unsafe)) ) ) ] + (set! unsafe (cons var unsafe)) ) + (set! previous (remove (lambda (p) (eq? (car p) var)) previous)))] [(if ##core#cond ##core#switch) (scan (first subs) e) @@ -85,17 +86,18 @@ [(set!) (let ([var (first params)]) - (and-let* ((p (alist-ref var previous))) - (compiler-warning - 'var - "dropping assignment of unused value to global variable `~s'" - var) - (copy-node! - (make-node '##core#undefined '() '()) - p)) (scan (first subs) e) - (unless (memq var e) (mark var)) - (remember var n) )] + (let ((p (alist-ref var previous))) + (when (and p (not (memq var unsafe))) + (compiler-warning + 'var + "dropping assignment of unused value to global variable `~s'" + var) + (copy-node! + (make-node '##core#undefined '() '()) + p)) + (unless (memq var e) (mark var)) + (remember var n) ) ) ] [else (scan-each subs e)] ) ) )Trap