GNU bug report logs -
#75498
31.0.50; cl-block is not lexically scoped
Previous Next
Reported by: Ihor Radchenko <yantar92 <at> posteo.net>
Date: Sat, 11 Jan 2025 16:09:01 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
Message #8 received at 75498 <at> debbugs.gnu.org (full text, mbox):
> From: Ihor Radchenko <yantar92 <at> 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.
This bug report was last modified 129 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.