Subject: bug#77464: X is already defined as something else than a generic function

From: Jonas Bernoulli <[email-masked]>
Date: Mon, 14 Apr 2025 20:14:19 +0200

Hello Stefan

Stefan Monnier <[email-masked]> writes:
>>> Now that I have finally done that, I also managed to come of with a
>>> reproducer.
>>> 
>>> 1. Create a file "demo.el" with contents:
>>> 
>>> (require 'eieio)
>>> (defclass demo-class () ())
>>> (cl-defmethod demo-function ((obj demo-class)) obj)
>>> 
>>> (error "something else goes wrong here")
>>> (provide 'demo)
>
> I pushed to `master` what I think should fix this problem.
> Can you try again?

That fixed the issue.  It's now also easier to understand why, when and
how this avoids recording the location.

Of course that won't fix the issue for released Emacsen, and for anyone
who runs into this and has not seen this thread that continues to be
very confusing.  Can you think of any workaround beside making sure that
each and every generic function is first declared using cl-defgeneric?

>> Then, after this function has returned, something else goes wrong (in
>> this reproducer intentionally).  We can then observe that the value of
>> (symbol-function 'demo-function) somehow goes back to being 'dummy.
>> (I couldn't find anything else in Emacs that sets a symbol-function to
>> 'dummy.)

Could you please explain what was happening?  To me this still looks
like the value somehow magically goes back to 'dummy.

     Thanks!
     Jonas