[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 134edc1 2/2: Warn about wrong number of args for
From: |
Noam Postavsky |
Subject: |
[Emacs-diffs] emacs-26 134edc1 2/2: Warn about wrong number of args for subrs (Bug#35767) |
Date: |
Thu, 30 May 2019 18:48:23 -0400 (EDT) |
branch: emacs-26
commit 134edc10367a8434167656e631865c85b5f10c42
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>
Warn about wrong number of args for subrs (Bug#35767)
* lisp/emacs-lisp/bytecomp.el (byte-compile-callargs-warn): Don't
assume byte-compile-fdefinition will return non-nil.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-warn-wrong-args)
(bytecomp-warn-wrong-args-subr): New tests.
---
lisp/emacs-lisp/bytecomp.el | 2 +-
test/lisp/emacs-lisp/bytecomp-tests.el | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 9ea4179..72e81a6 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1379,7 +1379,7 @@ when printing the error message."
(defun byte-compile-callargs-warn (form)
(let* ((def (or (byte-compile-fdefinition (car form) nil)
(byte-compile-fdefinition (car form) t)))
- (sig (byte-compile--function-signature def))
+ (sig (byte-compile--function-signature (or def (car form))))
(ncall (length (cdr form))))
;; Check many or unevalled from subr-arity.
(if (and (cdr-safe sig)
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el
b/test/lisp/emacs-lisp/bytecomp-tests.el
index bc28c5a..c399f65 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -438,6 +438,20 @@ Subtests signal errors if something goes wrong."
;; Should not warn that mt--test2 is not known to be defined.
(should-not (re-search-forward "my--test2" nil t))))
+(ert-deftest bytecomp-warn-wrong-args ()
+ (with-current-buffer (get-buffer-create "*Compile-Log*")
+ (let ((inhibit-read-only t)) (erase-buffer))
+ (byte-compile '(remq 1 2 3))
+ (ert-info ((buffer-string) :prefix "buffer: ")
+ (should (re-search-forward "remq.*3.*2")))))
+
+(ert-deftest bytecomp-warn-wrong-args-subr ()
+ (with-current-buffer (get-buffer-create "*Compile-Log*")
+ (let ((inhibit-read-only t)) (erase-buffer))
+ (byte-compile '(safe-length 1 2 3))
+ (ert-info ((buffer-string) :prefix "buffer: ")
+ (should (re-search-forward "safe-length.*3.*1")))))
+
(ert-deftest test-eager-load-macro-expansion ()
(test-byte-comp-compile-and-load nil
'(progn (defmacro abc (arg) 1) (defun def () (abc 2))))