Subject: Re: bug#53071: 28.0.90; Emacs 28 regression: incorrect code generation for complex pcase forms?

From: Philipp <[email-masked]>
Date: Wed, 12 Jan 2022 03:19:42 +0100

> Am 07.01.2022 um 10:36 schrieb Philipp Stephani <[email-masked]>:
> 
> 
> I hit the following subtle Edebug regression in Emacs 28:
> 
> Create a file /tmp/pcase-edebug.el with these contents:
> 
> $ cat /tmp/pcase-edebug.el 
> ;; -*- lexical-binding: t; -*-
> (require 'rx)
> (defun f (a)
>  (pcase a
>    ((rx bos (let q (opt (let r nonl)) (let a nonl)))
>     (message "%s" a))
>    ((rx bos eos)
>     (message "%s" a))))
> 
> Visit the file in Emacs:
> 
> $ emacs -Q -l rx /tmp/pcase-edebug.el
> 
> Move point into the `f' function and instrument it using C-u C-M-x.
> Then, byte-compile `f' using M-: (byte-compile 'f).
> In Emacs 28, this will generate the following warnings:
> 
> Warning: Unused lexical variable `q'
> Warning: Unused lexical variable `r'
> Warning: reference to free variable ‘a’
> 
> The first two are expected, the third one is not.
> Indeed, M-: (f "ab") and stepping through the code will signal an error:
> 
>   Symbol's value as variable is void: a

'git bisect' claims that the following commit is the culprit:

commit 1362a9fec4dff341a84c881ac17dbf1ee2cf82fd
Author: Mattias Engdegård <[email-masked]>
Date:   Fri Mar 5 20:21:01 2021 +0100

    Make lambda-lifting work again