GNU bug report logs - #62959
[PATCH] Recognize defstruct slot names in various eieio functions

Previous Next

Package: emacs;

Reported by: Thuna <thuna.cing <at> gmail.com>

Date: Wed, 19 Apr 2023 22:17:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 62959 in the body.
You can then email your comments to 62959 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#62959; Package emacs. (Wed, 19 Apr 2023 22:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thuna <thuna.cing <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 19 Apr 2023 22:17:02 GMT) Full text and rfc822 format available.

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

From: Thuna <thuna.cing <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Recognize defstruct slot names in various eieio functions
Date: Thu, 20 Apr 2023 00:15:50 +0200
[Message part 1 (text/plain, inline)]
The function `eieio--known-slot-name-p' is used by some eieio functions
(specifically eieio-oref, eieio-oref-default, and eieio-oset-default) to
check whether a slot name is known or not, and if not signals an
"Unknown slot" warning.

Structs do not make their slots known to `eieio--known-slot-name-p', so
the warning is signaled even for valid slot names.  Since eieio aims for
compatibility with defstruct, this should probably be considered a bug.

The function `eieio--known-slot-name-p' checks the variable
`eieio--known-slot-names' but also has a fallback for the name's
`slot-name' property.  In the patch I opted to use the latter.

[0001-Recognize-defstruct-slot-names-in-various-eieio-func.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62959; Package emacs. (Thu, 20 Apr 2023 06:51:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Thuna <thuna.cing <at> gmail.com>,
 Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 62959 <at> debbugs.gnu.org
Subject: Re: bug#62959: [PATCH] Recognize defstruct slot names in various eieio
 functions
Date: Thu, 20 Apr 2023 09:50:46 +0300
> From: Thuna <thuna.cing <at> gmail.com>
> Date: Thu, 20 Apr 2023 00:15:50 +0200
> 
> The function `eieio--known-slot-name-p' is used by some eieio functions
> (specifically eieio-oref, eieio-oref-default, and eieio-oset-default) to
> check whether a slot name is known or not, and if not signals an
> "Unknown slot" warning.
> 
> Structs do not make their slots known to `eieio--known-slot-name-p', so
> the warning is signaled even for valid slot names.  Since eieio aims for
> compatibility with defstruct, this should probably be considered a bug.
> 
> The function `eieio--known-slot-name-p' checks the variable
> `eieio--known-slot-names' but also has a fallback for the name's
> `slot-name' property.  In the patch I opted to use the latter.
> 
> 
> >From 86ed1ed7d024a0d40286d5fe4697258dc98a1b9e Mon Sep 17 00:00:00 2001
> From: Thuna <thuna.cing <at> gmail.com>
> Date: Wed, 19 Apr 2023 23:43:22 +0200
> Subject: [PATCH] Recognize defstruct slot names in various eieio functions
> 
> * lisp/emacs-lisp/cl-preloaded.el (cl-struct-define): Set each slot's
> name's `slot-name' property so that `eieio--known-slot-name-p' can
> recognize them.
> ---
>  lisp/emacs-lisp/cl-preloaded.el | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
> index 9445093f143..5235be52996 100644
> --- a/lisp/emacs-lisp/cl-preloaded.el
> +++ b/lisp/emacs-lisp/cl-preloaded.el
> @@ -176,6 +176,7 @@ cl-struct-define
>                         (i 0)
>                         (offset (if type 0 1)))
>                     (dolist (slot slots)
> +                     (put (car slot) 'slot-name t)
>                       (let* ((props (cl--plist-to-alist (cddr slot)))
>                              (typep (assq :type props))
>                              (type (if (null typep) t
> -- 
> 2.39.2
> 

Stefan, any comments?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#62959; Package emacs. (Tue, 02 May 2023 20:49:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 62959 <at> debbugs.gnu.org, Thuna <thuna.cing <at> gmail.com>
Subject: Re: bug#62959: [PATCH] Recognize defstruct slot names in various
 eieio functions
Date: Tue, 02 May 2023 16:48:02 -0400
>> diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
>> index 9445093f143..5235be52996 100644
>> --- a/lisp/emacs-lisp/cl-preloaded.el
>> +++ b/lisp/emacs-lisp/cl-preloaded.el
>> @@ -176,6 +176,7 @@ cl-struct-define
>>                         (i 0)
>>                         (offset (if type 0 1)))
>>                     (dolist (slot slots)
>> +                     (put (car slot) 'slot-name t)
>>                       (let* ((props (cl--plist-to-alist (cddr slot)))
>>                              (typep (assq :type props))
>>                              (type (if (null typep) t
>> -- 
>> 2.39.2
>> 
>
> Stefan, any comments?

LGTM, thanks,


        Stefan





Reply sent to Eli Zaretskii <eliz <at> gnu.org>:
You have taken responsibility. (Wed, 03 May 2023 11:47:02 GMT) Full text and rfc822 format available.

Notification sent to Thuna <thuna.cing <at> gmail.com>:
bug acknowledged by developer. (Wed, 03 May 2023 11:47:02 GMT) Full text and rfc822 format available.

Message #16 received at 62959-done <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 62959-done <at> debbugs.gnu.org, thuna.cing <at> gmail.com
Subject: Re: bug#62959: [PATCH] Recognize defstruct slot names in various
 eieio functions
Date: Wed, 03 May 2023 14:47:10 +0300
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Thuna <thuna.cing <at> gmail.com>,  62959 <at> debbugs.gnu.org
> Date: Tue, 02 May 2023 16:48:02 -0400
> 
> >> diff --git a/lisp/emacs-lisp/cl-preloaded.el b/lisp/emacs-lisp/cl-preloaded.el
> >> index 9445093f143..5235be52996 100644
> >> --- a/lisp/emacs-lisp/cl-preloaded.el
> >> +++ b/lisp/emacs-lisp/cl-preloaded.el
> >> @@ -176,6 +176,7 @@ cl-struct-define
> >>                         (i 0)
> >>                         (offset (if type 0 1)))
> >>                     (dolist (slot slots)
> >> +                     (put (car slot) 'slot-name t)
> >>                       (let* ((props (cl--plist-to-alist (cddr slot)))
> >>                              (typep (assq :type props))
> >>                              (type (if (null typep) t
> >> -- 
> >> 2.39.2
> >> 
> >
> > Stefan, any comments?
> 
> LGTM, thanks,

Thanks, installed on the emacs-29 branch, and closing.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 01 Jun 2023 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 329 days ago.

Previous Next


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