[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#55914: 28.1; Defining as dynamic an already lexical var
From: |
Lars Ingebrigtsen |
Subject: |
bug#55914: 28.1; Defining as dynamic an already lexical var |
Date: |
Sun, 12 Jun 2022 12:33:59 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Hendrik Tews <hendrik.tews@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