GNU bug report logs - #46387
28.0.50; Compiled code making a variable dynamic stopped working

Previous Next

Package: emacs;

Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>

Date: Mon, 8 Feb 2021 17:31:02 UTC

Severity: normal

Found in version 28.0.50

Done: Mattias EngdegÄrd <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Mattias EngdegÄrd <mattiase <at> acm.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 46387 <at> debbugs.gnu.org
Subject: bug#46387: 28.0.50; Compiled code making a variable dynamic stopped working
Date: Tue, 9 Feb 2021 17:49:20 +0100
9 feb. 2021 kl. 16.31 skrev Stefan Monnier <monnier <at> iro.umontreal.ca>:

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

All right, `defvar` modifies the current scope and only let, let* and lambda create new scopes. Fine, but it leaves questions unanswered.

* Does `defvar` affect new bindings only, or variable references in the current scope as well? In

 (let ((my-var EXPR))
   (defvar my-var)
   (use my-var))

does the last line refer to the lexical my-var bound in the first line, or to the dynamic my-var?

* Does the defvar have to be 'executed' to be effective? That's how the interpreter works, but it clearly can't work in the compiler. The defvar form probably has to 'precede' the binding form which it tries to affect, in some way.

> 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.

Yes, but it does (currently) work if used on a single variable at a time, which is the suggested workaround for the time being.





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

Previous Next


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