Subject: bug#65017: 29.1; Byte compiler interaction with cl-lib function objects, removes symbol-function

From: Mattias Engdegård <[email-masked]>
Date: Thu, 3 Aug 2023 11:39:33 +0200

> Error: invalid-function (#<symbol equal at 95>)

That is a symbol-with-position somehow leaking out.
We can simplify your nice little test case to

------- first file -----------
(require 'cl-macs)
(defun zeta () (cl-flet () #'equal))
------- second file ---------
(defun eta () (cl-flet () (funcall #'equal 12 34)))
------------------------------

and indeed, the leak is in cl--labels-convert-cache which will contain `equal` as a symbol-with-pos after byte-compiling the first file, and this causes trouble in the second file.

cl--labels-convert-cache contains

  (#<symbol equal at 49> function #<symbol equal at 49>)

and the function `eta` is consequently defined as

  (closure (t) nil (progn (#<symbol equal at 49> 12 34)))

where 49 is the position of `equal` in the first file.

Stefan and Alan should have a word here but I doubt we should hack this in cl-macs.el somehow, should we?
Making Ffuncall (etc) tolerant of symbol-with-pos isn't appealing either.