GNU bug report logs - #55914
28.1; Defining as dynamic an already lexical var

Previous Next

Package: emacs;

Reported by: Hendrik Tews <hendrik.tews <at> kernkonzept.com>

Date: Sat, 11 Jun 2022 21:34:01 UTC

Severity: normal

Found in version 28.1

Full log


View this message in rfc822 format

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Hendrik Tews <hendrik.tews <at> kernkonzept.com>
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>, 55914 <at> debbugs.gnu.org
Subject: bug#55914: 28.1; Defining as dynamic an already lexical var
Date: Sun, 12 Jun 2022 12:33:59 +0200
Hendrik Tews <hendrik.tews <at> kernkonzept.com> writes:

> The elisp manual 28.1 says in 12.5 Defining Global Variables:
>
>      If SYMBOL is already lexically bound (e.g., if the ‘defvar’ form
>      occurs in a ‘let’ form with lexical binding enabled), then ‘defvar’
>      sets the dynamic value.
>
>>From this I would conclude that the error is a bug. Or did I
> overlook something in the documentation?

There's been some back and forth about what happens in these cases.
This section in the manual currently reads (in Emacs 29):

---
If @var{symbol} is already let bound (e.g., if the @code{defvar}
form occurs in a @code{let} form), then @code{defvar} sets the toplevel
default value, like @code{set-default-toplevel-value}.
---

However, your test case signals an error, so I think the documentation
needs further clarifications here:

    (let ((test-var nil))
      (eval '(defvar test-var t "XXX")))

I've added Stefan to the CCs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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

Previous Next


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