From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Odd warning about `customize-variable' Date: Wed, 11 May 2022 17:22:26 -0400 Message-ID: References: <87y1z8cp67.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="444"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed May 11 23:23:45 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1noto8-000AT9-UH for ged-emacs-devel@m.gmane-mx.org; Wed, 11 May 2022 23:23:45 +0200 Original-Received: from localhost ([::1]:47180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1noto7-0000FB-Rc for ged-emacs-devel@m.gmane-mx.org; Wed, 11 May 2022 17:23:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1notn0-0007nP-OJ for emacs-devel@gnu.org; Wed, 11 May 2022 17:22:34 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1notmy-00013y-Lq for emacs-devel@gnu.org; Wed, 11 May 2022 17:22:34 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C1D351002CB; Wed, 11 May 2022 17:22:28 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 408E310010F; Wed, 11 May 2022 17:22:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1652304147; bh=+6rHvIu/R7lnACNxGLDyEJB7WUkw+z5yvm7+gZGWE/w=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=dSh46e4Qt0Log2Fwhsbwl4h+xPLrOrylHaWQXFxtf1H3Wd4xU8bc7lE5nqrA1oKGv 31NmmNpEdqmMqJkeVQHmkTtVoNPCH5jMejDT64EmU76W8dmVRLas8E0WY9+y/GUuxY 5CMrSzOGkzqKYUWnbvvV7oOCmuQawnhM7ZYJZEFCjP38fQa7lBFNU8wJs9MYPMtfhF GfjNefzKzFFIx4QGhjDRUyw7m6hoz7IRIQ9NfZw9vFFHFmlTkAWeKbNdUTufgfLVNf pIgvpbXgyR4XiwPyR/z1E+utt5SGMj0fmmjQyCQaqSDbgxckNH58joCTntgYw4aBnv 2ecFZ16CukE7Q== Original-Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2EC4B120758; Wed, 11 May 2022 17:22:27 -0400 (EDT) In-Reply-To: <87y1z8cp67.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 11 May 2022 12:57:20 +0200") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:289649 Archived-At: 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)