* bug#75498: 31.0.50; cl-block is not lexically scoped
@ 2025-01-11 16:10 Ihor Radchenko
2025-01-11 16:40 ` Eli Zaretskii
0 siblings, 1 reply; 2+ messages in thread
From: Ihor Radchenko @ 2025-01-11 16:10 UTC (permalink / raw)
To: 75498
According to the docstring, `cl-block' should be lexically scoped:
Code inside the BODY forms can call cl-return-from
to jump prematurely out of the block. This differs from catch and throw
in two respects: First, the NAME is an unevaluated symbol rather than a
quoted symbol or other form; and second, NAME is lexically rather than
dynamically scoped: Only references to it within BODY will work. These
references may appear inside macro expansions, but not inside functions
called from BODY.
But try the following reproducer:
1. create file test.el
;; -*- lexical-binding: t; -*-
(defun return-from-x ()
(cl-return-from x 'dynamic))
(defun x-block ()
(cl-block x
(return-from-x)
(cl-return-from x 'lexical)))
2. (load "/path/to/test.el)
3. M-: (x-block)
Expected: 'lexical is returned.
Observed: 'dynamic is returned.
In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.42, cairo version 1.18.2) of 2025-01-10 built on localhost
Repository revision: e8deac66adef279a15c806d7547a7610b0189795
Repository branch: scratch/igc
Windowing system distributor 'The X.Org Foundation', version 11.0.12101014
System Description: Gentoo Linux
Configured using:
'configure --with-mps=yes --with-native-compilation 'CFLAGS=-g3
-I/opt/mps/include -L/opt/mps/lib'
JAVAC=/etc/java-config-2/current-system-vm/bin/javac
PKG_CONFIG_PATH=/usr/share/guile-data/3.0/pkgconfig'
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#75498: 31.0.50; cl-block is not lexically scoped
2025-01-11 16:10 bug#75498: 31.0.50; cl-block is not lexically scoped Ihor Radchenko
@ 2025-01-11 16:40 ` Eli Zaretskii
0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2025-01-11 16:40 UTC (permalink / raw)
To: Ihor Radchenko, Stefan Monnier; +Cc: 75498
> From: Ihor Radchenko <yantar92@posteo.net>
> Date: Sat, 11 Jan 2025 16:10:39 +0000
>
>
> According to the docstring, `cl-block' should be lexically scoped:
>
> Code inside the BODY forms can call cl-return-from
> to jump prematurely out of the block. This differs from catch and throw
> in two respects: First, the NAME is an unevaluated symbol rather than a
> quoted symbol or other form; and second, NAME is lexically rather than
> dynamically scoped: Only references to it within BODY will work. These
> references may appear inside macro expansions, but not inside functions
> called from BODY.
>
> But try the following reproducer:
>
> 1. create file test.el
>
> ;; -*- lexical-binding: t; -*-
>
> (defun return-from-x ()
> (cl-return-from x 'dynamic))
>
> (defun x-block ()
> (cl-block x
> (return-from-x)
> (cl-return-from x 'lexical)))
>
> 2. (load "/path/to/test.el)
> 3. M-: (x-block)
>
> Expected: 'lexical is returned.
> Observed: 'dynamic is returned.
Adding Stefan.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-11 16:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-11 16:10 bug#75498: 31.0.50; cl-block is not lexically scoped Ihor Radchenko
2025-01-11 16:40 ` Eli Zaretskii
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).