[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd warning about `customize-variable'
From: |
Stefan Monnier |
Subject: |
Re: Odd warning about `customize-variable' |
Date: |
Wed, 11 May 2022 17:22:26 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
Lars Ingebrigtsen [2022-05-11 12:57:20] wrote:
> org/org.el:15523:6: Warning: the function `customize-variable' might not be
> defined at runtime.
>
> This is odd, because loaddefs has:
>
> (defalias 'customize-variable 'customize-option)
> (autoload 'customize-option "cus-edit" "\
Here's what happens:
org.el does:
(eval-when-compile (require 'gnus-sum))
which ends up loading `message` which loads `eudc-capf` which loads
`eudc` which calls `custom-menu-create` which loads `cus-edit`.
Loading `cus-edit` (re)defines `customize-variable` as an actual
function (rather than an alias) and adds a corresponding entry in
`load-history`.
At the end of `eval-when-compile`, `byte-compile-eval` looks at that
`load-history` and (mistakenly) thinks that `customize-variable` was
previously not defined.
This is because it does:
(`(defun . ,f)
(unless (seq-some #'autoloadp
(get f 'function-history))
(push f byte-compile-noruntime-functions)))))))))))))
so it only skips the case where the function used to be defined as an
autoload, but not when it used to be defined as an alias.
I installed the patch below which should fix this false positive,
hopefully without introducing too many false negatives.
Another way to attack the problem could be to change `defalias` so it
doesn't push any entry into `load-history` when the new value is equal
to the old one.
Stefan
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index cbf2659109a..de51a7731eb 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -1056,8 +1056,14 @@ byte-compile-eval
(dolist (s xs)
(pcase s
(`(defun . ,f)
- (unless (seq-some #'autoloadp
- (get (cdr s) 'function-history))
+ ;; If `f' has a history, it's presumably because
+ ;; it was already defined beforehand (typically
+ ;; as an autoload). It could also be because it
+ ;; was defined twice during `form', in which case
+ ;; we arguably should add it to b-c-noruntime-functions,
+ ;; but it's not clear it's worth the trouble
+ ;; trying to recognize that case.
+ (unless (get f 'function-history)
(push f byte-compile-noruntime-functions)))))))))))))
(defun byte-compile-eval-before-compile (form)