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.

Full log


View this message in rfc822 format

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Sean Devlin <spd <at> toadstyle.org>
Cc: 43601 <at> debbugs.gnu.org
Subject: 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






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

Previous Next


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