From: Lars Ingebrigtsen <larsi@gnus.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13814@debbugs.gnu.org, Jorgen Schaefer <forcer@forcix.cx>
Subject: bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar
Date: Mon, 23 Aug 2021 03:21:26 +0200 [thread overview]
Message-ID: <87y28tt0q1.fsf@gnus.org> (raw)
In-Reply-To: <jwvmwusosdx.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 25 Feb 2013 19:03:05 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Thanks for filing it, so we have a clear bug-number for this long
> standing problem. If someone wants to take a crack at fixing it,
> I think that we should add a `set-toplevel-default' which defvar and
> defcustom could use, as for how to implement it, I you can take a look
> at the check&warning in the C code of `defvar'.
When running this from M-: now, I get the following backtrace:
Debugger entered--Lisp error: (error "Defining as dynamic an already lexical var")
(defvar bug-variable t "This variable is not defined when autoloaded.")
eval-buffer(#<buffer *load*> nil "/tmp/bug-lib.el" nil t) ; Reading at buffer position 74
load-with-code-conversion("/tmp/bug-lib.el" "/tmp/bug-lib.el" nil t)
(bug-variable-value)
(let ((bug-variable nil)) (bug-variable-value))
eval((let ((bug-variable nil)) (bug-variable-value)) t)
eval-expression((let ((bug-variable nil)) (bug-variable-value)) nil nil 127)
funcall-interactively(eval-expression (let ((bug-variable nil)) (bug-variable-value)) nil nil 127)
call-interactively(eval-expression nil nil)
So this signals an error when doing the
(let ((bug-variable nil))
(bug-variable-value))
from a lexical context.
And... from a dynamic context, it seems like this works as it should
now? That is, the defvar "punches through" the let binding and defines
the variable properly. (Which I didn't know; last time I looked at
this, it didn't work, but it's some years back.)
Has this been fixed, or am I testing it wrong somehow?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
next prev parent reply other threads:[~2021-08-23 1:21 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-25 19:30 bug#13814: 24.3.50; Dynamic variables shadowing prevent defvar Jorgen Schaefer
2013-02-25 23:15 ` Glenn Morris
2013-02-26 0:03 ` Stefan Monnier
2021-08-23 1:21 ` Lars Ingebrigtsen [this message]
2021-08-24 21:25 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 11:00 ` Lars Ingebrigtsen
2021-08-25 14:41 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-08-25 16:03 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y28tt0q1.fsf@gnus.org \
--to=larsi@gnus.org \
--cc=13814@debbugs.gnu.org \
--cc=forcer@forcix.cx \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.