GNU bug report logs - #77725
31.0.50; Add support for types accepted by `cl-typep' to cl-generic?

Previous Next

Package: emacs;

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

Date: Fri, 11 Apr 2025 07:16:01 UTC

Severity: normal

Found in version 31.0.50

Full log


Message #92 received at 77725 <at> debbugs.gnu.org (full text, mbox):

From: David Ponce <da_vid <at> orange.fr>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 77725 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#77725: 31.0.50; Add support for types accepted by `cl-typep'
 to cl-generic?
Date: Thu, 24 Apr 2025 13:44:09 +0200
[Message part 1 (text/plain, inline)]
On 2025-04-23 14:59, David Ponce wrote:
> 
> While working with cl-types.el I discovered a nasty side effect
> of byte compilation on the cl--type-list.
> 
> I can't explain what is going on :-(
> 
> Here is a recipe:
> 
> - run emacs -Q
> 
> - load cl-type.el (the last version previously attached)
> 
> - load cl-type-recipe.el (attached)
> 
> - In the scratch buffer eval cl--type-list.  Result is expected:
> 
>    (cons-cdr-foo cons-car-foo)
> 
> - Then open cl-type-recipe.el and byte-compile it with
>    M-x emacs-lisp-byte-compile
> 
> - Then eval again cl--type-list in the scratch buffer, and now the
>    result is something like this:
> 
>    (#<symbol cons-cdr-foo at 158> #<symbol cons-car-foo at 46>)
> 
>    Which completely breaks cl-types !
> 
> I hope you can shed some light on what is going on here.
> 
> Thanks!
> 

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
[cl-type-recipe2.el (text/x-emacs-lisp, attachment)]

This bug report was last modified 10 days ago.

Previous Next


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