summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-04-11 17:12:06 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-04-11 17:12:06 -0700
commitfe1324ffb8d64e33036563c6e64a03df4bf6adda (patch)
tree9dedf781c6acdccb5a2b73ee2de93f38f18d7dc5
parentbb550cd603adf92c5389a3aff6db96353cdf6339 (diff)
downloadtxr-fe1324ffb8d64e33036563c6e64a03df4bf6adda.tar.gz
txr-fe1324ffb8d64e33036563c6e64a03df4bf6adda.tar.bz2
txr-fe1324ffb8d64e33036563c6e64a03df4bf6adda.zip
compiler: bugfix: rest parameter in inline lambda
* share/txr/stdlib/compiler.tl (lambda-apply-transform): Do not take all of the fixed arguments and rest expression to be the trailing list. Rather, skip as many elements from these as the function has fixed parameters. E.g. if there are two fixed parameters as in (lambda (a b . c)) and the call specifies four fixed parameters and a trailing x (1 2 3 4 . x) then the rest argument c must be (list* 3 4 . x) and not (list* 1 2 3 4 . x).
-rw-r--r--share/txr/stdlib/compiler.tl5
1 files changed, 4 insertions, 1 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index a96ba684..e00004a2 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -2036,7 +2036,10 @@
(null pars.opt))
(if fix-vals
(if pars.rest
- (add ^(,pars.rest (list* ,*fix-arg-exprs ,apply-list-expr)))
+ (add ^(,pars.rest
+ (list*
+ ,*(nthcdr pars.nfix
+ ^(,*fix-arg-exprs ,apply-list-expr)))))
(lambda-too-many-args lm-expr))
(when (or pars.rest apply-list-expr)
(add ^(,(or pars.rest ign-sym) ,apply-list-expr)))))