From fe1324ffb8d64e33036563c6e64a03df4bf6adda Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 11 Apr 2021 17:12:06 -0700 Subject: 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). --- share/txr/stdlib/compiler.tl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'share') 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))))) -- cgit v1.2.3