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
commit2f721b742766663c6f5bf6c6fb8011c796c3ce0f (patch)
tree9dedf781c6acdccb5a2b73ee2de93f38f18d7dc5
parent25a6e90f324a36bc8155e20458232f7e7ac41fb2 (diff)
downloadtxr-2f721b742766663c6f5bf6c6fb8011c796c3ce0f.tar.gz
txr-2f721b742766663c6f5bf6c6fb8011c796c3ce0f.tar.bz2
txr-2f721b742766663c6f5bf6c6fb8011c796c3ce0f.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)))))