GNU bug report logs - #43601
27.1; Macroexpansion bug in `push'

Previous Next

Package: emacs;

Reported by: Sean Devlin <spd <at> toadstyle.org>

Date: Thu, 24 Sep 2020 22:56:01 UTC

Severity: normal

Tags: fixed

Found in version 27.1

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.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 43601 in the body.
You can then email your comments to 43601 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 bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Thu, 24 Sep 2020 22:56:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sean Devlin <spd <at> toadstyle.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 24 Sep 2020 22:56:01 GMT) Full text and rfc822 format available.

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

From: Sean Devlin <spd <at> toadstyle.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.1; Macroexpansion bug in `push'
Date: Thu, 24 Sep 2020 18:54:59 -0400
Hi folks,

I believe I've found a macroexpansion bug in the `push' macro. Open a
new instance of Emacs and evaluate the following form in the scratch
buffer:

    (macroexpand '(push (list 'x)
                        (cdr my-list)))

The result (with some reformatting) is this:

    (let* ((v (list 'x))
           (v my-list))
      (setcdr v
              (cons v
                   (cdr v))))

Both values are bound to `v', so the former is shadowed by the latter.

Thanks!


In GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95))
of 2020-08-12 built on builder10-14.porkrind.org
Windowing system distributor 'Apple', version 10.3.2011
System Description:  macOS 11.0

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set
(x y)
See buffer *Pp Macroexpand Output*.
You can run the command ‘pp-macroexpand-last-sexp’ with M-x p-m-l RET
See buffer *Pp Macroexpand Output*.
Making completion list...

Configured using:
'configure --with-ns '--enable-locallisppath=/Library/Application
Support/Emacs/${version}/site-lisp:/Library/Application
Support/Emacs/site-lisp' --with-modules'

Configured features:
NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES
THREADS JSON PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x seq
byte-opt bytecomp byte-compile cconv mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils help-mode easymenu
cl-loaddefs cl-lib gv pp tooltip eldoc electric uniquify ediff-hook
vc-hooks lisp-float-type mwheel term/ns-win ns-win ucs-normalize
mule-util term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 46943 7509)
(symbols 48 6030 1)
(strings 32 15598 2351)
(string-bytes 1 514024)
(vectors 16 10404)
(vector-slots 8 132291 12524)
(floats 8 28 38)
(intervals 56 218 0)
(buffers 1000 13))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Thu, 24 Sep 2020 23:18:01 GMT) Full text and rfc822 format available.

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

From: Sean Devlin <spd <at> toadstyle.org>
To: 43601 <at> debbugs.gnu.org
Subject: Re: bug#43601: Acknowledgement (27.1; Macroexpansion bug in `push')
Date: Thu, 24 Sep 2020 19:17:30 -0400
Hi folks,

Upon closer inspection, it looks like the two bindings are distinct. I guess the symbols must be created by `make-symbol’ or similar. Still, it might be nice for debugging if the symbols had distinct names.

Thanks!



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Fri, 25 Sep 2020 05:57:02 GMT) Full text and rfc822 format available.

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

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 43601 <at> debbugs.gnu.org
Subject: Re: bug#43601: 27.1; Macroexpansion bug in `push'
Date: Fri, 25 Sep 2020 17:56:09 +1200
On 2020-09-25 10:54, Sean Devlin wrote:
> Hi folks,
> 
> I believe I've found a macroexpansion bug in the `push' macro. Open a
> new instance of Emacs and evaluate the following form in the scratch
> buffer:
> 
>     (macroexpand '(push (list 'x)
>                         (cdr my-list)))
> 
> The result (with some reformatting) is this:
> 
>     (let* ((v (list 'x))
>            (v my-list))
>       (setcdr v
>               (cons v
>                    (cdr v))))
> 
> Both values are bound to `v', so the former is shadowed by the latter.

It's actually fine.

What you're seeing is the *printed representation* of the lisp objects,
and two completely independent symbols, each with the name "v".

(setq foo (macroexpand '(push (list 'x) (cdr my-list))))
=> (let* ((v (list 'x)) (v my-list)) (setcdr v (cons v (cdr v))))

(setq vfirst (caaadr foo))
=> v

(setq vsecond (car (cadadr foo)))
=> v

(eq vfirst vsecond)
=> nil

(cdaddr (caddr foo))
=> (v (cdr v))

(eq vfirst (car (cdaddr (caddr foo))))
=> t

(eq vsecond (cadadr (cdaddr (caddr foo))))
=> t


This is like:

(eq (make-symbol "v") (make-symbol "v"))
=> nil






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Fri, 25 Sep 2020 09:36:02 GMT) Full text and rfc822 format available.

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

From: Philipp Stephani <p.stephani2 <at> gmail.com>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 43601 <at> debbugs.gnu.org
Subject: Re: bug#43601: 27.1; Macroexpansion bug in `push'
Date: Fri, 25 Sep 2020 11:35:35 +0200
Am Fr., 25. Sept. 2020 um 00:56 Uhr schrieb Sean Devlin <spd <at> toadstyle.org>:
>
> Hi folks,
>
> I believe I've found a macroexpansion bug in the `push' macro. Open a
> new instance of Emacs and evaluate the following form in the scratch
> buffer:
>
>     (macroexpand '(push (list 'x)
>                         (cdr my-list)))
>
> The result (with some reformatting) is this:
>
>     (let* ((v (list 'x))
>            (v my-list))
>       (setcdr v
>               (cons v
>                    (cdr v))))
>
> Both values are bound to `v', so the former is shadowed by the latter.


These are different uninterned symbols:

(let ((print-gensym t) (print-circle t))
  (print (macroexpand '(push (list 'x) (cdr my-list))))
  nil)

⇒ (let* ((#2=#:v (list 'x)) (#1=#:v my-list)) (setcdr #1# (cons #2# (cdr #1#))))

In general, if you see a "weird" expansion like this, bind
print-gensym to non-nil to see the uninterned symbols.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Fri, 25 Sep 2020 09:41:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: Sean Devlin <spd <at> toadstyle.org>, 43601 <at> debbugs.gnu.org
Subject: Re: bug#43601: 27.1; Macroexpansion bug in `push'
Date: Fri, 25 Sep 2020 11:40:19 +0200
Philipp Stephani <p.stephani2 <at> gmail.com> writes:

> In general, if you see a "weird" expansion like this, bind
> print-gensym to non-nil to see the uninterned symbols.

True.  But we could change push to use a different name for the
gensymmed symbol to avoid confusions like this.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43601; Package emacs. (Sat, 26 Sep 2020 15:06:01 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Philipp Stephani <p.stephani2 <at> gmail.com>
Cc: Sean Devlin <spd <at> toadstyle.org>, 43601 <at> debbugs.gnu.org
Subject: Re: bug#43601: 27.1; Macroexpansion bug in `push'
Date: Sat, 26 Sep 2020 17:05:32 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Philipp Stephani <p.stephani2 <at> gmail.com> writes:
>
>> In general, if you see a "weird" expansion like this, bind
>> print-gensym to non-nil to see the uninterned symbols.
>
> True.  But we could change push to use a different name for the
> gensymmed symbol to avoid confusions like this.

I've now done so in Emacs 28.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) fixed. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 26 Sep 2020 15:06:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 28.1, send any further explanations to 43601 <at> debbugs.gnu.org and Sean Devlin <spd <at> toadstyle.org> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 26 Sep 2020 15:06: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. (Sun, 25 Oct 2020 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 316 days ago.

Previous Next


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