From a46ef5d5b56f0ca6f69a36ddf131bc3b9658b758 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(-) (limited to 'share') 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