Subject: bug#43601: 27.1; Macroexpansion bug in `push'

From: Philipp Stephani <[email-masked]>
Date: Fri, 25 Sep 2020 11:35:35 +0200

Am Fr., 25. Sept. 2020 um 00:56 Uhr schrieb Sean Devlin <[email-masked]>:
>
> 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.