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

From: Stefan Monnier <[email-masked]>
Date: Sat, 05 Aug 2023 18:53:48 -0400

>> I don't know why `symbols-with-pos-enabled` is non-nil at that point (I
>> thought we only enabled it wile byte-compiling), ....
>
> This is not quite the case.  symbols-with-pos-enabled gets erroneously
> bound to t in internal-macroexpand-for-load (emacs-lisp/macroexp.el).

Aha!

> diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
> index b05aba3e1a7..ea838f5b7b2 100644
> --- a/lisp/emacs-lisp/macroexp.el
> +++ b/lisp/emacs-lisp/macroexp.el
> @@ -799,8 +799,7 @@ macroexp--debug-eager
>  
>  (defun internal-macroexpand-for-load (form full-p)
>    ;; Called from the eager-macroexpansion in readevalloop.
> -  (let ((symbols-with-pos-enabled t)
> -        (print-symbols-bare t))
> +  (let ((print-symbols-bare t))
>      (cond
>       ;; Don't repeat the same warning for every top-level element.
>       ((eq 'skip (car macroexp--pending-eager-loads)) form)

Looks good to me.  AFAICT this binding was added at some point where it
seemed like a good idea but we later figured better places to do it,
and we just didn't remove it because it seemed "harmless" (or because
we just didn't think of it).

> Stefan, it would still be nice for cl--labels-convert-cache to get
> initialised each time it gets used.

No, the problem is not initialization, as I pointed out.  The problem is
that this `eq` should not consider a symbol equal to a sympos *ever*
(contrary to most other uses of `eq` in macros).

        Stefan