Commit 977e2fab authored by Marius Gerbershagen's avatar Marius Gerbershagen
Browse files

cmp: fix inlining of functions with &key and &aux arguments

&aux arguments come after &key ones.

Fixes #633.
parent 83ed2e17
......@@ -640,8 +640,6 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
`(list ,@arguments))
(if apply-p apply-var nil)))
let-vars))
(loop while aux-vars
do (push (list (pop aux-vars) (pop aux-vars)) let-vars))
(do ((scan (cdr keywords) (cddddr scan)))
((endp scan))
(let ((keyword (first scan))
......@@ -660,6 +658,8 @@ The function thus belongs to the type of functions that ecl_make_cfun accepts."
let-vars))))
(when (and key-flag (not allow-other-keys))
(push `(si::check-keyword ,rest ',all-keys) extra-stmts))
(loop while aux-vars
do (push (list (pop aux-vars) (pop aux-vars)) let-vars))
(values (nreverse (delete-if-not #'first let-vars))
`(,@(and apply-var `((declare (ignorable ,apply-var))))
,@(multiple-value-bind (decl body)
......
......@@ -2013,3 +2013,27 @@
(multiple-value-list
(funcall
(compile nil '(lambda () (values (values)))))))))
;;; Date 2021-03-25
;;; URL: https://gitlab.com/embeddable-common-lisp/ecl/-/issues/633
;;; Description
;;;
;;; The order of function arguments was wrong when inlining a
;;; function with &key and &aux arguments. This test checks
;;; correct ordering in general.
(test cmp.0086.inline-ordering-function-arguments
(is (equal (multiple-value-list
(funcall (compile nil '(lambda ()
(flet ((f (a
&optional (b a)
&rest c
&key (d c)
&aux (e d))
(list a b c d e)))
(declare (inline f))
(values (f 1)
(f 1 2)
(f 1 2 :d 3)))))))
'((1 1 nil nil nil)
(1 2 nil nil nil)
(1 2 (:d 3) 3 3)))))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment