GNU bug report logs - #78056
31.0.50; bug in `cl-eval-when` with symbols with positions

Previous Next

Package: emacs;

Reported by: David Ponce <da_vid <at> orange.fr>

Date: Fri, 25 Apr 2025 07:39:01 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: David Ponce <da_vid <at> orange.fr>
To: 78056 <at> debbugs.gnu.org
Subject: bug#78056: 31.0.50; bug in `cl-eval-when` with symbols with positions
Date: Fri, 25 Apr 2025 09:37:58 +0200
[Message part 1 (text/plain, inline)]
Hello,

Following advice of S. Monnier, I am creating this specific bug report for
this issue discovered while working on bug report #77725. I am copying
the messages exchanged on this subject here.

I attached the test file cl-type-recipe2.el for the mentioned simple recipe
to reproduce the issue.

Thanks!

> On 2025-04-24 13:44, David Ponce wrote:
>> It seems the side effect is more general than just with cl-type.el.
>>
>> I attached cl-type-recipe2.el, another simple recipe to illustrate with
>> current `cl-deftype'.
>>
>> - Run emacs -Q and load cl-type-recipe2.el.
>> - Then in the scratch buffer eval:
>>
>> (symbol-plist 'cons-car-foo)
>> => (cl-deftype-handler #[nil ((list 'satisfies #'(lambda (x) (eq (car-safe x) 'foo)))) (t) nil "A cons with a `foo' car."])
>>
>> - Then open cl-type-recipe2.el and M-x emacs-lisp-byte-compile
>>
>> - Then in the scratch buffer eval again:
>>
>> (symbol-plist 'cons-car-foo)
>> => (cl-deftype-handler #[nil (`(#<symbol satisfies at 113> ,(#<symbol lambda at 125> (x) (#<symbol eq at 137> (#<symbol car-safe at 141> #<symbol x at 150>) '#<symbol foo at 154>)))) (t) nil "A cons with a `foo' car."])
>>
>> And, of course:
>>
>> (cl-typep '(foo) 'cons-car-foo)
>> => (invalid-function #<symbol lambda at 125>)
>>
>> Without compile in the `cl-eval-when' in `cl-deftype', there is no side effect.
>>
>> Hope it will help.
>>
>> David
> 
> Another information which could be useful: if I replace (cl-eval-when (compile load eval) ...)
> by (eval-and-compile ...) in the definition of `cl-deftype', there is no side effect
> of the byte-compilation on the current definition.
> 
> What I don't know is if the two forms are equivalent.
> 
> 

On 2025-04-24 21:44, Stefan Monnier wrote:
>> Another information which could be useful: if I replace (cl-eval-when
>> (compile load eval) ...)  by (eval-and-compile ...) in the definition
>> of `cl-deftype', there is no side effect of the byte-compilation on
>> the current definition.
> 
> It looks like this is a bug in `cl-eval-when` introduced when Alan added
> "symbol with positions" for better error reporting.
> 
> Could you make it a separate bug-report?
> 
>> What I don't know is if the two forms are equivalent.
> 
> Obviously they don't do quite the same thing, but AFAIK they *should*
> behave the same, so I'd use `eval-and-compile`.
> 
> 
>          Stefan
> 

In GNU Emacs 31.0.50 (build 3, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.2) of 2025-04-22
Repository revision: 871ec9615a949e967bf7d19466eb9c56ed80ff7e
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101016
System Description: Fedora Linux 41 (KDE Plasma)

Configured using:
 'configure --with-native-compilation=no
 PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM
XRANDR GTK3 ZLIB

Important settings:
  value of $LC_TIME: fr_FR.utf8
  value of $LANG: fr_FR.UTF-8
  locale-coding-system: utf-8-unix
[cl-type-recipe2.el (text/x-emacs-lisp, attachment)]

This bug report was last modified 49 days ago.

Previous Next


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