From 9b8131e81d15c8726ddd6c51d66691ebeb4ebdcd Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Mon, 9 Jun 2025 12:55:11 +0200 Subject: [PATCH] Revert "Fix function arity check for noncompiled callees (bug#78685)" This reverts commit 8b0f5b05976a99e82e54d6c602d47a8668ccd9d5. This change wasn't quite right; the solution requires greater care. (cherry picked from commit 7f6244364b73f0200704708babf6d22367898912) --- lisp/emacs-lisp/bytecomp.el | 7 +++++-- test/lisp/emacs-lisp/bytecomp-tests.el | 14 -------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 15c55315af5..74385e79a80 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1463,7 +1463,10 @@ when printing the error message." (let ((fn name)) (while (and (symbolp fn) (fboundp fn) - (functionp (symbol-function fn))) + (or (symbolp (symbol-function fn)) + (consp (symbol-function fn)) + (and (not macro-p) + (compiled-function-p (symbol-function fn))))) (setq fn (symbol-function fn))) (let ((advertised (get-advertised-calling-convention (if (and (symbolp fn) (fboundp fn)) @@ -1475,7 +1478,7 @@ when printing the error message." (if macro-p `(macro lambda ,advertised) `(lambda ,advertised))) - ((and (not macro-p) (functionp fn)) fn) + ((and (not macro-p) (compiled-function-p fn)) fn) ((not (consp fn)) nil) ((eq 'macro (car fn)) (cdr fn)) (macro-p nil) diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index d1f272f7a4d..8b0c1dad4c0 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el @@ -1357,20 +1357,6 @@ byte-compiled. Run with dynamic binding." (concat ";;; -*-lexical-binding:nil-*-\n" some-code))) (should (cookie-warning some-code)))))) -(defun bytecomp-tests--f (x y &optional u v) (list x y u v)) - -(ert-deftest bytecomp-tests--warn-arity-noncompiled-callee () - "Check that calls to non-compiled functions are arity-checked (bug#78685)" - (should (not (compiled-function-p (symbol-function 'bytecomp-tests--f)))) - (let* ((source (concat ";;; -*-lexical-binding:t-*-\n" - "(defun my-fun () (bytecomp-tests--f 11))\n")) - (lexical-binding t) - (log (bytecomp-tests--log-from-compilation source))) - (should (string-search - (concat "Warning: `bytecomp-tests--f' called with 1 argument," - " but requires 2-4") - log)))) - (ert-deftest bytecomp-tests--unescaped-char-literals () "Check that byte compiling warns about unescaped character literals (Bug#20852)." -- 2.39.5