From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 13 11:20:59 2025 Received: (at submit) by debbugs.gnu.org; 13 Jun 2025 15:20:59 +0000 Received: from localhost ([127.0.0.1]:48364 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQ6D9-0003qC-K0 for submit@debbugs.gnu.org; Fri, 13 Jun 2025 11:20:58 -0400 Received: from lists.gnu.org ([2001:470:142::17]:55254) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQ6D7-0003pZ-9W for submit@debbugs.gnu.org; Fri, 13 Jun 2025 11:20:54 -0400 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 1uQ6Cu-0005Xb-5r for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 11:20:40 -0400 Received: from mail-4316.protonmail.ch ([185.70.43.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uQ6Cr-0003Vj-SK for bug-gnu-emacs@gnu.org; Fri, 13 Jun 2025 11:20:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1749828035; x=1750087235; bh=iTgSQtQYVJPPQN/TVjNEbqfWfxd3QiWMhbU/jUkvxE0=; h=Date:To:From:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=ehP/S4FqJYhdNeR+R4Dauj+//0WHRHsPgn6P6YfduYiUexXxi0l56u09Hw3MFd+Ge XSsEKP5/J3XUKyihvXgWxjWQt/Y96z7NIdomrtXG52tULw4a7FdxRL5V19VQaqIiET 79LyTbW/B2HgLxffMfhcDy8bLlewIn8NNSBOoMkVla++ikPaqvfRCgiQrNVEQ6+Wl7 HL+iXJY45H1pGjQKEk/OzE3gjq0sQ+ofUxK0zKH8t97JXlrRD4HbntW+h4HltE28cM 4EIv72TcSQ1ZiZpCt/jaU4ThGxlt1dQkpJVp2yrRgyT6NnBoeWZSADpUcQ/RtvveA+ UwrDUvBMjHf2A== Date: Fri, 13 Jun 2025 15:20:32 +0000 To: bug-gnu-emacs@gnu.org From: Pip Cet Subject: 31.0.50; eieio-core.el requires byte compilation Message-ID: <87zfebwtvn.fsf@protonmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 5c50ec6db8ae671554d0b56e0ee940b5420a3d2a MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.43.16; envelope-from=pipcet@protonmail.com; helo=mail-4316.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) Evaluating eieio-core.el without compilation currently results in breakage: (load "eieio-core.el") (cl-defstruct foo x) (eieio-oset (make-foo) 'x nil) results in: signal(wrong-type-argument (eieio--class #s(cl-structure-class :name foo = :docstring nil :parents (#s(cl-structure-class :name cl-structure-object :d= ocstring "The root parent of all \"normal\" CL structs" :parents (#s(built-= in-class :name record :docstring "Abstract type of objects with slots." :pa= rents (...) :slots nil :index-table nil)) :slots [] :index-table # :tag cl-structure-object :type nil :named nil :print t :chil= dren-sym cl-struct-cl-structure-object-tags)) :slots [#s(cl-slot-descriptor= :name x :initform nil :type t :props nil)] :index-table # :tag foo :type nil :named nil :print t :children-sym cl-struct-foo-t= ags))) (or (let* ((cl-x cl-x)) (and (memq (type-of cl-x) cl-struct-eieio--class-= tags) t)) (signal 'wrong-type-argument (list 'eieio--class cl-x))) (progn (or (let* ((cl-x cl-x)) (and (memq (type-of cl-x) cl-struct-eieio-= -class-tags) t)) (signal 'wrong-type-argument (list 'eieio--class cl-x))) (= aref cl-x 4)) (let* ((cl-x class)) (progn (or (let* ((cl-x cl-x)) (and (memq (type-of c= l-x) cl-struct-eieio--class-tags) t)) (signal 'wrong-type-argument (list 'e= ieio--class cl-x))) (aref cl-x 4))) (aref (let* ((cl-x class)) (progn (or (let* ((cl-x cl-x)) (and (memq (typ= e-of cl-x) cl-struct-eieio--class-tags) t)) (signal 'wrong-type-argument (l= ist 'eieio--class cl-x))) (aref cl-x 4))) slot-idx) (let* ((sd (aref (let* ((cl-x class)) (progn (or (let* ... ...) (signal .= .. ...)) (aref cl-x 4))) slot-idx)) (st (let* ((cl-x sd)) (progn (or (let* = (...) (and ... t)) (signal 'wrong-type-argument (list ... cl-x))) (aref cl-= x 3))))) (cond ((not (eieio--perform-slot-validation st value)) (signal 'in= valid-slot-type (list (let* ((cl-x class)) (progn (or ... ...) (aref cl-x 1= ))) slot st value))) ((alist-get :read-only (let* ((cl-x sd)) (progn (or (l= et* ... ...) (signal ... ...)) (aref cl-x 4)))) (signal 'eieio-read-only (l= ist (let* ((cl-x class)) (progn (or ... ...) (aref cl-x 1))) slot))))) (if eieio-skip-typecheck nil (setq slot-idx (- slot-idx '1)) (let* ((sd (= aref (let* ((cl-x class)) (progn (or ... ...) (aref cl-x 4))) slot-idx)) (s= t (let* ((cl-x sd)) (progn (or (let* ... ...) (signal ... ...)) (aref cl-x = 3))))) (cond ((not (eieio--perform-slot-validation st value)) (signal 'inva= lid-slot-type (list (let* (...) (progn ... ...)) slot st value))) ((alist-g= et :read-only (let* ((cl-x sd)) (progn (or ... ...) (aref cl-x 4)))) (signa= l 'eieio-read-only (list (let* (...) (progn ... ...)) slot)))))) eieio--validate-slot-value(#s(cl-structure-class :name foo :docstring nil= :parents (#s(cl-structure-class :name cl-structure-object :docstring "The = root parent of all \"normal\" CL structs" :parents (#s(built-in-class :name= record :docstring "Abstract type of objects with slots." :parents (#s(buil= t-in-class :name atom :docstring "Abstract supertype of anything but cons c= ells." :parents ... :slots nil :index-table nil)) :slots nil :index-table n= il)) :slots [] :index-table # :tag cl-structure-obje= ct :type nil :named nil :print t :children-sym cl-struct-cl-structure-objec= t-tags)) :slots [#s(cl-slot-descriptor :name x :initform nil :type t :props= nil)] :index-table # :tag foo :type nil :named nil = :print t :children-sym cl-struct-foo-tags) 1 nil x) The expected behavior is for this code to complete without error. The failure is because eieio--validate-slot-value is called for a class (object) of type cl-structure-object, but calls eieio--class-slots on that object; it could call cl--class-slots instead, and then this bug wouldn't happen. When byte-compiled, we optimize out the type checks so everything works. This is achieved by the cl-declaim calls surrounding the cl-defstruct of eieio--class. When interpreted directly, cl-defstruct always adds the type checks, so the error pops up. However, I have my doubts about whether we might end up calling eieio--class-class-slots or eieio--class-initarg-tuples on a cl-structure-object, which would return its "type" or "named" slots (unless I miscounted, sorry). So I'd like to fix these while we're there (in the latter case, we're on slow code paths so this should not be a problem; in the former case, if there is a performance impact, we could consider moving the class-slots slot to cl--class instead, reserving a useless slot in it for cl-structure-object objects). I propose moving to cl--class-* accessors where we can, and calling eieio--class-slot-name-index and eieio--class-initarg-to-attribute only on known/checked eieio--class objects. But if an alternative is desired (I think this may be the case because I suggested changing one of the accessors before), and the initarg/class-slot case is always safe, we could simply error out when trying to evaluate eieio-core.el directly rather than compiling it. While this is related to bug#78685, I think there are other, non-bug-induced circumstances in which we end up interpreting eieio-core.el, so we should either allow it or make it fail less subtly.