Subject: bug#62959: closed (Re: bug#62959: [PATCH] Recognize defstruct slot names in various eieio functions)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 03 May 2023 11:47:02 +0000

Your bug report

#62959: [PATCH] Recognize defstruct slot names in various eieio functions

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
62959: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62959
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#62959: [PATCH] Recognize defstruct slot names in various eieio functions
From: Eli Zaretskii <[email-masked]>
To: Stefan Monnier <[email-masked]>
Cc: [email-masked], [email-masked]
Date: Wed, 03 May 2023 14:47:10 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> From: Stefan Monnier <[email-masked]>
> Cc: Thuna <[email-masked]>,  [email-masked]
> 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.

Subject: [PATCH] Recognize defstruct slot names in various eieio functions
From: Thuna <[email-masked]>
To: [email-masked]
Date: Thu, 20 Apr 2023 00:15:50 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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 <[email-masked]>
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