GNU bug report logs - #78786
31.0.50; eieio-core.el requires byte compilation

Previous Next

Package: emacs;

Reported by: Pip Cet <pipcet <at> protonmail.com>

Date: Fri, 13 Jun 2025 15:21:01 UTC

Severity: normal

Found in version 31.0.50

Done: Pip Cet <pipcet <at> protonmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Pip Cet <pipcet <at> protonmail.com>
Cc: 78786 <at> debbugs.gnu.org
Subject: Re: bug#78786: 31.0.50; eieio-core.el requires byte compilation
Date: Sat, 05 Jul 2025 17:30:37 -0400
>> Yes, calling `eieio--class-slot-name-index` on non-EIEIO classes is
>> a bug, we should fix the code to do it only when it is an EIEIO class.
>
> So this?

LGTM, yes.


        Stefan


> diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el
> index 72640e88301..6d9a0199ea6 100644
> --- a/lisp/emacs-lisp/eieio-core.el
> +++ b/lisp/emacs-lisp/eieio-core.el
> @@ -740,7 +740,8 @@ eieio-oref
>        (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 @@ eieio-oref-default
>      (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 @@ eieio-oset
>        (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 (eieie--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 @@ eieio-oset-default
>      (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)
> diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
> index fced6bc3df2..f00914d9fe9 100644
> --- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
> +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
> @@ -1047,7 +1047,8 @@ eieio-test-defstruct-slot-value
>                  (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)
> +    (should-error (eieio-oref x 'd) :type 'invalid-slot-name)))
>  
>  (defclass foo-bug-66938 (eieio-instance-inheritor)
>    ((x :initarg :x
>
> The new test didn't actually fail before, but I figured it might catch
> some future bug.
>
> Pip





This bug report was last modified 8 days ago.

Previous Next


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