From a1bab9c5e9cfeb780f75fe5d363c22bdc193dcce Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 28 Feb 2019 19:26:44 -0800 Subject: 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)). --- share/txr/stdlib/compiler.tl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'share') 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 -- cgit v1.2.3