]> git.eshelyaron.com Git - emacs.git/commitdiff
Call eieio--class-* accessors only on eieio classes (bug#78786)
authorPip Cet <pipcet@protonmail.com>
Wed, 9 Jul 2025 15:16:07 +0000 (15:16 +0000)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 07:54:47 +0000 (09:54 +0200)
* lisp/emacs-lisp/eieio-core.el (eieio-oref, eieio-oref-default):
(eieio-oset, eieio-oset-default): Don't look for class slots except in
eieio classes.
* test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
(eieio-test-defstruct-slot-value): New test.

(cherry picked from commit 6a5d9cb07d6ef8c8913acb304eea365c85d82449)

lisp/emacs-lisp/eieio-core.el
test/lisp/emacs-lisp/eieio-tests/eieio-tests.el

index 0beca666c48ff8161a31f0a37a967c74f9f39f49..a88473ee792d7f0ff40f9e8cd383deeeacc3896e 100644 (file)
@@ -740,7 +740,8 @@ Argument FN is the function calling this verifier."
       (if (not c)
          ;; It might be missing because it is a :class allocated slot.
          ;; Let's check that info out.
-         (if (setq c (eieio--class-slot-name-index class slot))
+         (if (and (eieio--class-p class)
+                   (setq c (eieio--class-slot-name-index class slot)))
              ;; Oref that slot.
              (aref (eieio--class-class-allocation-values class) c)
            ;; The slot-missing method is a cool way of allowing an object author
@@ -783,8 +784,9 @@ Fills in CLASS's SLOT with its default value."
     (if (not c)
        ;; It might be missing because it is a :class allocated slot.
        ;; Let's check that info out.
-       (if (setq c
-                 (eieio--class-slot-name-index cl slot))
+       (if (and (eieio--class-p cl)
+                 (setq c
+                      (eieio--class-slot-name-index cl slot)))
            ;; Oref that slot.
            (aref (eieio--class-class-allocation-values cl)
                  c)
@@ -808,8 +810,9 @@ Fills in OBJ's SLOT with VALUE."
       (if (not c)
          ;; It might be missing because it is a :class allocated slot.
          ;; Let's check that info out.
-         (if (setq c
-                   (eieio--class-slot-name-index class slot))
+         (if (and (eieio--class-p class)
+                   (setq c
+                        (eieio--class-slot-name-index class slot)))
              ;; Oset that slot.
              (progn
                (eieio--validate-class-slot-value class c value slot)
@@ -849,7 +852,8 @@ Fills in the default value in CLASS' in SLOT with VALUE."
     (if (not c)
         ;; It might be missing because it is a :class allocated slot.
         ;; Let's check that info out.
-        (if (setq c (eieio--class-slot-name-index class slot))
+        (if (and (eieio--class-p class)
+                 (setq c (eieio--class-slot-name-index class slot)))
             (progn
               ;; Oref that slot.
               (eieio--validate-class-slot-value class c value slot)
index fced6bc3df24483b98b77682efb28794db5eda4e..b60db80ad56f33ee7032c78363b99ec5c8846e93 100644 (file)
@@ -1047,7 +1047,9 @@ Subclasses to override slot attributes."))
                 (slot-value x 'c)))
     (setf (slot-value x 'a) 1)
     (should (eq (eieio-test--struct-a x) 1))
-    (should-error (setf (slot-value x 'c) 3) :type 'eieio-read-only)))
+    (should-error (setf (slot-value x 'c) 3) :type 'eieio-read-only)
+    (with-no-warnings
+      (should-error (eieio-oref x 'd)) :type 'invalid-slot-name)))
 
 (defclass foo-bug-66938 (eieio-instance-inheritor)
   ((x :initarg :x