diff --git a/src/cmp/cmplam.lsp b/src/cmp/cmplam.lsp index a4c567332..42b163cc2 100644 --- a/src/cmp/cmplam.lsp +++ b/src/cmp/cmplam.lsp @@ -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) diff --git a/src/tests/normal-tests/compiler.lsp b/src/tests/normal-tests/compiler.lsp index e97577604..2291b89a4 100644 --- a/src/tests/normal-tests/compiler.lsp +++ b/src/tests/normal-tests/compiler.lsp @@ -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)))))