GNU bug report logs - #8646
byte-compile-initial-macro-environment confuses byte-compile-arglist-warn

Previous Next

Package: emacs;

Reported by: Glenn Morris <rgm <at> gnu.org>

Date: Tue, 10 May 2011 22:28:02 UTC

Severity: minor

Found in version 24.0.50

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 8646 in the body.
You can then email your comments to 8646 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Tue, 10 May 2011 22:28:02 GMT) Full text and rfc822 format available.

Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: submit <at> debbugs.gnu.org
Subject: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Tue, 10 May 2011 18:26:55 -0400
Package: emacs
Version: 24.0.50
Severity: minor

Since the lexical merge, compiling subr.el warns:

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

This is caused by the element in byte-compile-initial-macro-environment:
  (declare-function . byte-compile-macroexpand-declare-function)

This confuses byte-compile-arglist-warn, because
  (byte-compile-fdefinition 'declare-function t)

returns `byte-compile-macroexpand-declare-function', which leads to a
(bogus) arglist signature of 0+.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Wed, 11 May 2011 04:34:02 GMT) Full text and rfc822 format available.

Message #6 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
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))





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Wed, 11 May 2011 13:55:02 GMT) Full text and rfc822 format available.

Message #9 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Wed, 11 May 2011 10:54:02 -0300
> Here's a patch that I think might be right in general, but still leaves
> a warning in this specific case:

The patch looks right, thanks.  The "2+" vs "2-4" can be fixed by
changing either the macro definition of its override so that their
arglist matches.

> 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. (?)

The intention of byte-compile-initial-macro-environment is to override
"the" actual macro definition.  Obviously, this presumes that the macro is
not redefined elsewhere in a different way, otherwise the intended
behavior is not defined.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Wed, 11 May 2011 17:40:03 GMT) Full text and rfc822 format available.

Message #12 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Wed, 11 May 2011 13:39:15 -0400
Stefan Monnier wrote:

> The "2+" vs "2-4" can be fixed by changing either the macro definition
> of its override so that their arglist matches.

No, really? ;)

I don't see how to change the override definition to not use &rest,
since it is a function that needs to distinguish "no argument" from
"argument nil". And changing the macro to match the override seems like
putting the cart before the horse.

How about the following, based on the idea that it is the override that
should be congruent with the real macro definition, even though the
former gets defined first? It's the reason that
byte-compile-macroexpand-declare-function can work.


*** lisp/emacs-lisp/bytecomp.el	2011-05-11 17:32:38 +0000
--- lisp/emacs-lisp/bytecomp.el	2011-05-11 17:35:51 +0000
***************
*** 1321,1327 ****
      ;; Assumes an element of b-c-i-macro-env that is a symbol points
      ;; to a defined function.  (Bug#8646)
      (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))
--- 1321,1328 ----
      ;; Assumes an element of b-c-i-macro-env that is a symbol points
      ;; to a defined function.  (Bug#8646)
      (and initial (symbolp initial)
!          (setq old (byte-compile-fdefinition initial nil)
!                initial 'yes))
      (if (and old (not (eq old t)))
  	(progn
  	  (and (eq 'macro (car-safe old))
***************
*** 1334,1340 ****
                           ((pred byte-code-function-p) (aref old 0))
                           (t '(&rest def)))))
  		(sig2 (byte-compile-arglist-signature (nth 2 form))))
! 	    (unless (byte-compile-arglist-signatures-congruent-p sig1 sig2)
  	      (byte-compile-set-symbol-position name)
  	      (byte-compile-warn
  	       "%s %s used to take %s %s, now takes %s"
--- 1335,1345 ----
                           ((pred byte-code-function-p) (aref old 0))
                           (t '(&rest def)))))
  		(sig2 (byte-compile-arglist-signature (nth 2 form))))
! 	    ;; If something is on b-c-initial-m-e, *that* should be congruent
! 	    ;; with the normal (new) definition, not vice versa.
! 	    (unless (if (eq initial 'yes)
! 			(byte-compile-arglist-signatures-congruent-p sig2 sig1)
! 		      (byte-compile-arglist-signatures-congruent-p sig1 sig2))
  	      (byte-compile-set-symbol-position name)
  	      (byte-compile-warn
  	       "%s %s used to take %s %s, now takes %s"





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Thu, 12 May 2011 01:01:02 GMT) Full text and rfc822 format available.

Message #15 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Wed, 11 May 2011 22:00:03 -0300
>> The "2+" vs "2-4" can be fixed by changing either the macro definition
>> of its override so that their arglist matches.

> No, really? ;)

> I don't see how to change the override definition to not use &rest,
> since it is a function that needs to distinguish "no argument" from
> "argument nil". And changing the macro to match the override seems like
> putting the cart before the horse.

> How about the following, based on the idea that it is the override that
> should be congruent with the real macro definition, even though the
> former gets defined first? It's the reason that
> byte-compile-macroexpand-declare-function can work.

It makes some sense, indeed.  But I'm not thrilled about this solution.
I'd rather change the defmacro to match the override.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Thu, 19 May 2011 19:07:02 GMT) Full text and rfc822 format available.

Message #18 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Thu, 19 May 2011 15:06:35 -0400
Stefan Monnier wrote:

> It makes some sense, indeed.  But I'm not thrilled about this solution.
> I'd rather change the defmacro to match the override.

I think I'd rather put up with the warning.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8646; Package emacs. (Fri, 20 May 2011 02:20:02 GMT) Full text and rfc822 format available.

Message #21 received at 8646 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 8646 <at> debbugs.gnu.org
Subject: Re: bug#8646: byte-compile-initial-macro-environment confuses
	byte-compile-arglist-warn
Date: Thu, 19 May 2011 23:18:58 -0300
>> It makes some sense, indeed.  But I'm not thrilled about this solution.
>> I'd rather change the defmacro to match the override.
> I think I'd rather put up with the warning.

Good idea,


        Stefan




bug closed, send any further explanations to 8646 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 24 May 2011 00:46:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 21 Jun 2011 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 284 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.