Fix the subr-arity returned by native compiled functions with lots of args

This fixes bug #58739.  Make subr-arity return, e.g., (12 . 12) rather than
(12 . many) for a function with a fixed number of arguments more than 8.

* lisp/emacs-lisp/comp.el (comp-prepare-args-for-top-level): Only return a cdr
of 'many when there are &rest arguments.

* src/eval.c (eval_sub): Also check for a fixed number of args over 8 when
using the nargs + *args calling convention.
(funcall_subr): Also check numargs <= 8 before using the fixed args calling
convention.  Include the case numargs > 8 in the aMany calling convention.

* src/lisp.h (DEFUN): Amend the comment about MANY.
This commit is contained in:
Alan Mackenzie 2022-10-29 13:21:39 +00:00
parent 174dd06464
commit 31e7b9c073
3 changed files with 17 additions and 14 deletions

View file

@ -2057,9 +2057,10 @@ and the annotation emission."
"Lexically-scoped FUNCTION."
(let ((args (comp-func-l-args function)))
(cons (make-comp-mvar :constant (comp-args-base-min args))
(make-comp-mvar :constant (if (comp-args-p args)
(comp-args-max args)
'many)))))
(make-comp-mvar :constant (cond
((comp-args-p args) (comp-args-max args))
((comp-nargs-rest args) 'many)
(t (comp-nargs-nonrest args)))))))
(cl-defmethod comp-prepare-args-for-top-level ((function comp-func-d))
"Dynamically scoped FUNCTION."