GNU bug report logs - #49053
Error (setf seq-elt) is already defined as something else than a generic function

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Tue, 15 Jun 2021 22:07:02 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49053 in the body.
You can then email your comments to 49053 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org:
bug#49053; Package emacs. (Tue, 15 Jun 2021 22:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to monnier <at> iro.umontreal.ca, bug-gnu-emacs <at> gnu.org. (Tue, 15 Jun 2021 22:07:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Error (setf seq-elt) is already defined as something else than a
 generic function
Date: Wed, 16 Jun 2021 00:59:18 +0300
X-Debbugs-Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>

I'm creating a new bug report because I was able to reproduce it.

>>> (setf (seq-elt plist ...))
>>>
>>> may help with that, though.
>>
>> BTW, often after pulling from master and recompiling,
>> Emacs fails to start with such errors:
>>
>> Debugger entered--Lisp error: (error "(setf seq-elt) is already defined as
>> something else than a generic function")
>>   error("%s is already defined as something else than a generic function" \(setf\ seq-elt\))
>>   cl-generic-ensure-function(\(setf\ seq-elt\))
>>   cl-generic-define-method(\(setf\ seq-elt\) nil (store (sequence array) n)
>> nil #f(compiled-function (store sequence n)
>
> Hmm....
>
> When you see that, could you show us the value of:
>
>     (symbol-function '\(setf\ seq-elt\))

Here is what I did to reproduce the error:

1. Checked out 2f7a115a9c
2. make bootstrap
3. Checked out 794ec934a7
4. make (without bootstrap)
5. run emacs without -Q, i.e. with the init file

It terminated after printing to stderr:

  (setf seq-elt) is already defined as something else than a generic function

6. run `emacs -Q`

  (symbol-function '\(setf\ seq-elt\))
  => nil

7. loaded the init file from ~/.emacs

It printed to the *Messages* buffer:

  Load error for /home/juri/.emacs:
  (error (setf seq-elt) is already defined as something else than a generic function)

Then evaluated symbol-function again that returned a different value:

  (symbol-function '\(setf\ seq-elt\))
  => dummy

8. run again `emacs -Q` and tried to manually evaluate each expression
   in the init file.

Then at one point, the byte-compiler compiled the file bytecomp.eln
in ~/.emacs.d/eln-cache.  And the compiled bytecomp.eln completely
fixed the problem.

I guess some change between 2f7a115a9c and 794ec934a7 (maybe 663fb3b774)
changed the file bytecomp.el, so there was the need to recompile it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49053; Package emacs. (Tue, 15 Jun 2021 22:52:02 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: 49053 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#49053: Error (setf seq-elt) is already defined as something
 else than a generic function
Date: Wed, 16 Jun 2021 01:49:27 +0300
> 1. Checked out 2f7a115a9c
> 2. make bootstrap

Additional detail: after making bootstrap, started emacs with the init file,
and waited until it compiles all used eln files.

> 3. Checked out 794ec934a7
> 4. make (without bootstrap)
> 5. run emacs without -Q, i.e. with the init file
>
> It terminated after printing to stderr:
>
>   (setf seq-elt) is already defined as something else than a generic function




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49053; Package emacs. (Wed, 16 Jun 2021 02:30:02 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Juri Linkov <juri <at> linkov.net>
Cc: 49053 <at> debbugs.gnu.org
Subject: Re: bug#49053: Error (setf seq-elt) is already defined as something
 else than a generic function
Date: Tue, 15 Jun 2021 22:29:24 -0400
> Then evaluated symbol-function again that returned a different value:
>
>   (symbol-function '\(setf\ seq-elt\))
>   => dummy

I don't really understand why that would happen, but maybe too much
happens during `cl--generic-make-function`.  Does the patch below help?


        Stefan


diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 31aa0cb4f9..544704be38 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -568,17 +568,17 @@ cl-generic-define-method
               (cons method mt)
             ;; Keep the ordering; important for methods with :extra qualifiers.
             (mapcar (lambda (x) (if (eq x (car me)) method x)) mt)))
-    (let ((sym (cl--generic-name generic))) ; Actual name (for aliases).
+    (let ((sym (cl--generic-name generic)) ; Actual name (for aliases).
+          ;; FIXME: Try to avoid re-constructing a new function if the old one
+          ;; is still valid (e.g. still empty method cache)?
+          (gfun (cl--generic-make-function generic)))
       (unless (symbol-function sym)
         (defalias sym 'dummy))   ;Record definition into load-history.
       (cl-pushnew `(cl-defmethod . ,(cl--generic-load-hist-format
                                      (cl--generic-name generic)
                                      qualifiers specializers))
                   current-load-list :test #'equal)
-      ;; FIXME: Try to avoid re-constructing a new function if the old one
-      ;; is still valid (e.g. still empty method cache)?
-      (let ((gfun (cl--generic-make-function generic))
-            ;; Prevent `defalias' from recording this as the definition site of
+      (let (;; Prevent `defalias' from recording this as the definition site of
             ;; the generic function.
             current-load-list
             ;; BEWARE!  Don't purify this function definition, since that leads





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#49053; Package emacs. (Wed, 16 Jun 2021 08:34:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 49053 <at> debbugs.gnu.org
Subject: Re: bug#49053: Error (setf seq-elt) is already defined as something
 else than a generic function
Date: Wed, 16 Jun 2021 10:53:17 +0300
>>   (symbol-function '\(setf\ seq-elt\))
>>   => dummy
>
> I don't really understand why that would happen, but maybe too much
> happens during `cl--generic-make-function`.  Does the patch below help?

This patch helped - now emacs can be started without errors.




Forcibly Merged 47454 49053. Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Wed, 16 Jun 2021 16:57:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 49053, send any further explanations to 47454 <at> debbugs.gnu.org and scame <laszlomail <at> protonmail.com> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Wed, 16 Jun 2021 16:57:03 GMT) Full text and rfc822 format available.

Disconnected #49053 from all other report(s). Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 16 Jun 2021 17:09:02 GMT) Full text and rfc822 format available.

Severity set to 'normal' from 'wishlist' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 16 Jun 2021 17:09:02 GMT) Full text and rfc822 format available.

Removed tag(s) wontfix. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 16 Jun 2021 17:09:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 15 Jul 2021 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 257 days ago.

Previous Next


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