summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2017-07-14 11:27:21 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2017-07-14 11:27:21 -0400
commit6e2d6d54e1236216462c13655ea1fe573d9672e7 (patch)
treea5e1af3e57a5d1c3c7bf7828a60f6ab7c6e28f68 /lisp/emacs-lisp
parent583995c62dd424775dda33d5134ce04bee2ae685 (diff)
downloademacs-6e2d6d54e1236216462c13655ea1fe573d9672e7.tar.gz
emacs-6e2d6d54e1236216462c13655ea1fe573d9672e7.tar.bz2
emacs-6e2d6d54e1236216462c13655ea1fe573d9672e7.zip
* lisp/emacs-lisp/bytecomp.el: Fix bug#14860.
* lisp/emacs-lisp/bytecomp.el (byte-compile--function-signature): New fun. Dig into advice wrappers to find the "real" signature. (byte-compile-callargs-warn, byte-compile-arglist-warn): Use it. (byte-compile-arglist-signature): Don't bother with "new-style" arglists, since bytecode functions are now handled in byte-compile--function-signature. * lisp/files.el (create-file-buffer, insert-directory): Remove workaround introduced for (bug#14860). * lisp/help-fns.el (help-fns--analyse-function): `nadvice` is preloaded. * lisp/help.el (help-function-arglist): Dig into advice wrappers to find the "real" signature.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/bytecomp.el43
1 files changed, 15 insertions, 28 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index e5b9b47b1d0..fdd4276e4e7 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1263,12 +1263,6 @@ when printing the error message."
(defun byte-compile-arglist-signature (arglist)
(cond
- ;; New style byte-code arglist.
- ((integerp arglist)
- (cons (logand arglist 127) ;Mandatory.
- (if (zerop (logand arglist 128)) ;No &rest.
- (lsh arglist -8)))) ;Nonrest.
- ;; Old style byte-code, or interpreted function.
((listp arglist)
(let ((args 0)
opts
@@ -1289,6 +1283,19 @@ when printing the error message."
;; Unknown arglist.
(t '(0))))
+(defun byte-compile--function-signature (f)
+ ;; Similar to help-function-arglist, except that it returns the info
+ ;; in a different format.
+ (and (eq 'macro (car-safe f)) (setq f (cdr f)))
+ ;; Advice wrappers have "catch all" args, so fetch the actual underlying
+ ;; function to find the real arguments.
+ (while (advice--p f) (setq f (advice--cdr f)))
+ (if (eq (car-safe f) 'declared)
+ (byte-compile-arglist-signature (nth 1 f))
+ (condition-case nil
+ (let ((sig (func-arity f)))
+ (if (numberp (cdr sig)) sig (list (car sig))))
+ (error '(0)))))
(defun byte-compile-arglist-signatures-congruent-p (old new)
(not (or
@@ -1330,19 +1337,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 (if (and def (not (eq def t)))
- (progn
- (and (eq (car-safe def) 'macro)
- (eq (car-safe (cdr-safe def)) 'lambda)
- (setq def (cdr def)))
- (byte-compile-arglist-signature
- (if (memq (car-safe def) '(declared lambda))
- (nth 1 def)
- (if (byte-code-function-p def)
- (aref def 0)
- '(&rest def)))))
- (if (subrp (symbol-function (car form)))
- (subr-arity (symbol-function (car form))))))
+ (sig (byte-compile--function-signature def))
(ncall (length (cdr form))))
;; Check many or unevalled from subr-arity.
(if (and (cdr-safe sig)
@@ -1461,15 +1456,7 @@ extra args."
(and initial (symbolp initial)
(setq old (byte-compile-fdefinition initial nil)))
(when (and old (not (eq old t)))
- (and (eq 'macro (car-safe old))
- (eq 'lambda (car-safe (cdr-safe old)))
- (setq old (cdr old)))
- (let ((sig1 (byte-compile-arglist-signature
- (pcase old
- (`(lambda ,args . ,_) args)
- (`(closure ,_ ,args . ,_) args)
- ((pred byte-code-function-p) (aref old 0))
- (_ '(&rest def)))))
+ (let ((sig1 (byte-compile--function-signature old))
(sig2 (byte-compile-arglist-signature arglist)))
(unless (byte-compile-arglist-signatures-congruent-p sig1 sig2)
(byte-compile-set-symbol-position name)