Subject: bug#8646: byte-compile-initial-macro-environment confuses byte-compile-arglist-warn

From: Glenn Morris <[email-masked]>
Date: Wed, 11 May 2011 00:33:15 -0400

Here's a patch that I think might be right in general, but still leaves
a warning in this specific case:

In declare-function:
subr.el:39:11:Warning: macro declare-function used to take 2+ arguments,
  now takes 2-4

Strictly speaking, that warning is correct.

Actually, I guess this patch is not fully correct, because something
that is in byte-compile-initial-macro-environment could be redefined
more than once, in theory. But it's better than the current version. (?)

*** lisp/emacs-lisp/bytecomp.el	2011-05-07 04:03:49 +0000
--- lisp/emacs-lisp/bytecomp.el	2011-05-11 04:22:58 +0000
***************
*** 1314,1320 ****
  ;; number of arguments.
  (defun byte-compile-arglist-warn (form macrop)
    (let* ((name (nth 1 form))
!          (old (byte-compile-fdefinition name macrop)))
      (if (and old (not (eq old t)))
  	(progn
  	  (and (eq 'macro (car-safe old))
--- 1314,1327 ----
  ;; number of arguments.
  (defun byte-compile-arglist-warn (form macrop)
    (let* ((name (nth 1 form))
!          (old (byte-compile-fdefinition name macrop))
!          (initial (and macrop
!                        (cdr (assq name
!                                   byte-compile-initial-macro-environment)))))
!     ;; Assumes an element of b-c-i-macro-env that is a symbol points
!     ;; to a defined function.
!     (and initial (symbolp initial)
!          (setq old (byte-compile-fdefinition initial nil)))
      (if (and old (not (eq old t)))
  	(progn
  	  (and (eq 'macro (car-safe old))