summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-03-16 20:08:09 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-03-16 20:08:09 -0700
commit5014419c6458571453317c94f5be744515554196 (patch)
tree1ecc732ef39711fe43339286029e41425499a645
parent4920efac228b1174cfdcfcef9eb713859c1e52af (diff)
downloadtxr-5014419c6458571453317c94f5be744515554196.tar.gz
txr-5014419c6458571453317c94f5be744515554196.tar.bz2
txr-5014419c6458571453317c94f5be744515554196.zip
compiler: fix wrong, undersized frame size in closure.
* share/txr/stdlib/compiler.tl (compiler comp-lambda): Frame size can't be calculated from nfixed, because that doesn't account for the extra variables in optional parameters. It can't be calculated from the number of lexical variables either, because parameters that are special variables consume vXXYY frame entries without being counted as lexicals. Rather, the accurate frame size is given to us by the value of the counter in the newly created environment.
-rw-r--r--share/txr/stdlib/compiler.tl6
1 files changed, 3 insertions, 3 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index 684224a0..7842f558 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -251,8 +251,7 @@
(let* ((opt-pars (mapcar [iffi atom list] raw-opt-pars))
(nenv (if need-frame (new env up env co me) env))
(nreq (len req-pars))
- (nfixed (+ nreq (len opt-pars)))
- (frsize (+ nfixed (if rest-par 1 0))))
+ (nfixed (+ nreq (len opt-pars))))
(flet ((spec-sub (sym)
(cond
((special-var-p sym)
@@ -298,7 +297,8 @@
(benv (if specials (new env up nenv co me) nenv))
(bfrag me.(comp-progn benv body))
(oreg me.(alloc-treg))
- (lskip (gensym "l-")))
+ (lskip (gensym "l-"))
+ (frsize nenv.v-cntr))
me.(free-treg bfrag.oreg)
(new (frag oreg
^((close ,oreg ,frsize ,lskip ,nfixed ,nreq