From 1025ce941a8957b777545a4756a8b3cdfd16c242 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 16 Apr 2019 01:53:16 -0700 Subject: compiler: frame level mismatch bug. Repro test case: (defvar v) (defun f (: (v v))) (call (compile 'f)) ;; blows up * share/txr/stdlib/compiler.tl (compiler comp-lambda): The specials variable is wrongly used as a Boolean to decide whether we need an extra environment level for specials. The problem occurs when all of the specials are optional parameters. Optionals are handled specially and removed from the specials list. If all the specials are optional parameters, then the special list becomes empty. This cannot be intepreted as "there are no specials". The correct Boolean which indicates "there are specials" is need-dframe. --- share/txr/stdlib/compiler.tl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index e76849db..ccdbee83 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -868,7 +868,7 @@ ,*(whenlet ((spec-sub [find have-sym specials : cdr])) (set specials [remq have-sym specials cdr]) ^((bindv ,have-bind.loc ,me.(get-dreg (car spec-sub)))))))))) - (benv (if specials (new env up nenv co me) nenv)) + (benv (if need-dframe (new env up nenv co me) nenv)) (btreg me.(alloc-treg)) (bfrag me.(comp-progn btreg benv body)) (boreg (if env.(out-of-scope bfrag.oreg) btreg bfrag.oreg)) -- cgit v1.2.3