From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#62959: [PATCH] Recognize defstruct slot names in various eieio functions Date: Thu, 20 Apr 2023 09:50:46 +0300 Message-ID: <83cz3z6o8p.fsf@gnu.org> References: <87o7njv7qh.fsf@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37760"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62959@debbugs.gnu.org To: Thuna , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 20 08:51:23 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ppO8Z-0009go-5y for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 20 Apr 2023 08:51:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ppO8K-0003NX-7N; Thu, 20 Apr 2023 02:51:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppO8E-0003NH-Kx for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 02:51:06 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ppO8E-0006qN-6l for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 02:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ppO8D-0007Ma-Mj for bug-gnu-emacs@gnu.org; Thu, 20 Apr 2023 02:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 20 Apr 2023 06:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62959 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62959-submit@debbugs.gnu.org id=B62959.168197344228177 (code B ref 62959); Thu, 20 Apr 2023 06:51:01 +0000 Original-Received: (at 62959) by debbugs.gnu.org; 20 Apr 2023 06:50:42 +0000 Original-Received: from localhost ([127.0.0.1]:36351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppO7u-0007KN-Fp for submit@debbugs.gnu.org; Thu, 20 Apr 2023 02:50:42 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:45970) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ppO7s-0007KA-Le for 62959@debbugs.gnu.org; Thu, 20 Apr 2023 02:50:41 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppO7l-0006kx-SA; Thu, 20 Apr 2023 02:50:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=sb65ja3qV+EUuA3z7Txa7xjFDygpwFbfotGAHYhJKTU=; b=LBs6ZVc6gi4M 2eAJQIJT/5aXYn92cQqsrqJBfJ3F5bYQvX6GYmaNnc4QmnAfnQg6xTKmRr2tcxKweneIXBOjMCc/o di0KtW/wEC6d/8I6eQl3hRPVaQqC1e1c8MHT/4abJ/q2X/k2imJStYAG2jE1SxRv7xVRQC+lSF7vP CxXWKv5nIWx7qyn+8PVZkgK7LI7SF2wxQgrkUORdzjtDNz3RPNCuINe8f7K47ZUZZZjL/TqeUmNU1 c+sJyQSwxWPlj27X4K/+ENP6LPyXkxFdnZEevsRCHHPF5CCYlSFFK1dJrO5cT+Ee1PO3MV/tCJh59 sESBpimaZWVK6MxbjNOe1w==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ppO7k-0007FV-Bf; Thu, 20 Apr 2023 02:50:32 -0400 In-Reply-To: <87o7njv7qh.fsf@gmail.com> (message from Thuna on Thu, 20 Apr 2023 00:15:50 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:260310 Archived-At: > From: Thuna > 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 > 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?