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
commit522375d12bb5b0b295388f409e275e87c0cbb4ff (patch)
treefe921a44186d15eb69631f6c5cce6c66d0b1e00b
parent52599ee7d944b2dff38ca6f2cef283458bce8174 (diff)
downloadtxr-522375d12bb5b0b295388f409e275e87c0cbb4ff.tar.gz
txr-522375d12bb5b0b295388f409e275e87c0cbb4ff.tar.bz2
txr-522375d12bb5b0b295388f409e275e87c0cbb4ff.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