unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Odd warning about `customize-variable'
Date: Wed, 11 May 2022 17:22:26 -0400	[thread overview]
Message-ID: <jwvh75vn5xj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y1z8cp67.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 11 May 2022 12:57:20 +0200")

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)




  reply	other threads:[~2022-05-11 21:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 10:57 Odd warning about `customize-variable' Lars Ingebrigtsen
2022-05-11 21:22 ` Stefan Monnier [this message]
2022-05-12  0:33   ` Lars Ingebrigtsen
2022-05-12  0:38     ` Stefan Monnier
2022-05-12  0:54       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvh75vn5xj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).