Subject: bug#46387: 28.0.50; Compiled code making a variable dynamic stopped working

From: Stefan Monnier <[email-masked]>
Date: Tue, 09 Feb 2021 10:31:24 -0500

> There's a lack of clarity regarding the exact semantics of local
> `defvar`. The manual says that its effect is confined to the current
> lexical scope, but what exactly does that mean?

Adding a variable to the context creates a new scope.
A `progn` should not introduce a new scope.

> As it turns out, parts of the implementation have different opinions
> about that.

Indeed, there's a fair bit a space between my above two statements.

> As you observed, the recently added optimisation on master takes
> a strict syntactic view: even a `progn` is a lexical scope,

I think that's clearly an error.  Adding/removing `progn` shouldn't make
any difference in this respect.

> (Stefan, it looks like your latest Gnus patch may fall in the same trap. Or?)

The (with-suppressed-warnings (...) (defvar)) form is used at
several places.  It's the preferred way to declare a variable
dynamically scoped without incurring the "not prefixed" warning and
without making the `with-suppressed-warnings` silencer cover more code
than intended.

        Stefan