summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-02-28 19:26:44 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-02-28 19:26:44 -0800
commita1bab9c5e9cfeb780f75fe5d363c22bdc193dcce (patch)
treefe921a44186d15eb69631f6c5cce6c66d0b1e00b
parent6ddb270dcac7bc40a5f15a00fcbb035ee9c78286 (diff)
downloadtxr-a1bab9c5e9cfeb780f75fe5d363c22bdc193dcce.tar.gz
txr-a1bab9c5e9cfeb780f75fe5d363c22bdc193dcce.tar.bz2
txr-a1bab9c5e9cfeb780f75fe5d363c22bdc193dcce.zip
compiler: fix broken inline lambda.
* share/txr/stdlib/compiler.tl (lambda-apply-transform): Fix failure to bind the additional expresions to the rest variable, causing a too many arguments error to be reported. That is ((lambda (. x)) 1) would fail to compile. When binding the trailing fixed arguments to rest, we also pull in the apply list; this matches interpreted behavior, for instance ((lambda (a . b) (list a b)) 1 2 . 3) must return (1 (2 . 3)). In this case, the 3 comes into this function as (3) via the apply-list-expr argument; if we don't include that and bind only the remaining fix-args, then we get the output (1 (2)).
-rw-r--r--share/txr/stdlib/compiler.tl15
1 files changed, 9 insertions, 6 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl
index c11ca285..6ae10495 100644
--- a/share/txr/stdlib/compiler.tl
+++ b/share/txr/stdlib/compiler.tl
@@ -1498,13 +1498,16 @@
(while (and fix-arg-exprs pars.opt)
(add ^(,(car (pop pars.opt)) ,(pop fix-arg-exprs))))
(cond
- ((and (null fix-arg-exprs)
- (null pars.req)
+ ((and (null pars.req)
(null pars.opt))
- (when (or pars.rest apply-list-expr)
- (add ^(,(or pars.rest ign-sym) ,apply-list-expr))))
- (fix-arg-exprs
- (lambda-too-many-args lm-expr))
+ (if fix-arg-exprs
+ (if pars.rest
+ (add ^(,pars.rest (list* ,*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)))))
+ ((and fix-arg-exprs apply-list-expr)
+ (lambda-too-many-args lm-expr))
(apply-list-expr
(add ^(,al-val ,apply-list-expr))
(when pars.req