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

From: Stefan Monnier <[email-masked]>
Date: Tue, 15 Apr 2025 10:04:02 -0400

> 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?

Don't signal an error while loading a file?

>>> 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.

I have not worked out the details of the sequence of events, to be honest.
AFAICT, the "magic" comes from the code that tries to undo partial loads
when an error is encountered in the middle of loading a file (which
involves the `function-history` symbol property and the `Vautoload_queue`).
It's quite possible that it's a result of a bug in there.

        Stefan