~ chicken-core (chicken-5) b9898e4d1ae404b04316351c5de9329e7aa336b5
commit b9898e4d1ae404b04316351c5de9329e7aa336b5 Author: LemonBoy <thatlemon@gmail.com> AuthorDate: Mon Mar 27 16:05:23 2017 +0200 Commit: Evan Hanson <evhan@foldling.org> CommitDate: Mon Apr 10 07:11:21 2017 +1200 Fix a bug in scan-toplevel-assignments walk routine Commit [ac8f2dadd] introduced a bug in the node walking routine. We end up evaluating only the first two subexpression for some kind of nodes, this means the else branch for if/cond nodes is never walked and neither is most of ##core#switch since we stop the walk at the first constant node. Signed-off-by: Peter Bex <peter@more-magic.net> Signed-off-by: Evan Hanson <evhan@foldling.org> diff --git a/optimizer.scm b/optimizer.scm index 63a9b7d3..a6df2fde 100644 --- a/optimizer.scm +++ b/optimizer.scm @@ -71,8 +71,11 @@ (set! escaped #t) (set! previous '())) - (define (scan-each ns e) - (for-each (lambda (n) (scan n e)) ns) ) + (define (scan-each ns e clear-previous?) + (for-each (lambda (n) + (when clear-previous? (set! previous '())) + (scan n e)) + ns)) (define (scan n e) (let ([params (node-parameters n)] @@ -89,12 +92,10 @@ [(if ##core#cond ##core#switch) (scan (first subs) e) (touch) - (scan (first subs) e) - (set! previous '()) - (scan (second subs) e)] + (scan-each (cdr subs) e #t)] [(let) - (scan-each (butlast subs) e) + (scan-each (butlast subs) e #f) (scan (last subs) (append params e)) ] [(lambda ##core#lambda) #f] @@ -118,7 +119,7 @@ (unless (memq var e) (mark var)) (remember var n) ) ) ] - [else (scan-each subs e)] ) ) ) + [else (scan-each subs e #f)]))) (debugging 'p "scanning toplevel assignments...") (scan node '())Trap