From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Zack Weinberg" Newsgroups: gmane.emacs.bugs Subject: bug#64232: 28.2; Incorrect(?) byte compilation warning about =?UTF-8?Q?=E2=80=98ansi-color-apply-on-region=E2=80=99?= Date: Sat, 24 Jun 2023 11:15:42 -0400 Message-ID: <9c38fe1a-ee3a-4b6d-aaa7-33aa4909e331@app.fastmail.com> References: <874jmzs23h.wl-zack@owlfolio.org> <83o7l5yt9k.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8194"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.9.0-alpha0-499-gf27bbf33e2-fm-20230619.001-gf27bbf33 Cc: 64232@debbugs.gnu.org To: "Eli Zaretskii" , "Stefan Monnier" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jun 24 17:17:31 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1qD50z-0001p9-3m for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 24 Jun 2023 17:17:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qD50d-0001tP-CM; Sat, 24 Jun 2023 11:17:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qD50Y-0001sL-Jz for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 11:17:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qD50Y-0001I5-Bi for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 11:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qD50X-00086q-Vx for bug-gnu-emacs@gnu.org; Sat, 24 Jun 2023 11:17:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Zack Weinberg" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 24 Jun 2023 15:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64232 X-GNU-PR-Package: emacs Original-Received: via spool by 64232-submit@debbugs.gnu.org id=B64232.168761977631103 (code B ref 64232); Sat, 24 Jun 2023 15:17:01 +0000 Original-Received: (at 64232) by debbugs.gnu.org; 24 Jun 2023 15:16:16 +0000 Original-Received: from localhost ([127.0.0.1]:41318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qD4zn-00085a-TC for submit@debbugs.gnu.org; Sat, 24 Jun 2023 11:16:16 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:55405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qD4zi-00085F-Qw for 64232@debbugs.gnu.org; Sat, 24 Jun 2023 11:16:14 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 619715C00E4; Sat, 24 Jun 2023 11:16:05 -0400 (EDT) Original-Received: from imap45 ([10.202.2.95]) by compute1.internal (MEProxy); Sat, 24 Jun 2023 11:16:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm1; t= 1687619765; x=1687706165; bh=jUw8W/E5ZKTxIQRkRL8s1tyTfElBQNogCQV 4YwdS8E0=; b=Nt4lm6S9M9L4ZjMXYknIBLzkktcB6bO7b7+FhxvN6mJ9yz1WWe7 P7Cc2i3XpP65OCHRfSCL46mDsh/WUXiVJzUVkzCmDyR4ocO9oxYsbkMAp/gSlHtt IdpDE0RQIVkhqERMc6ZAsnOAM/yLOkC8VUOJrFmu/cv7oy7kH6bY8nGTcs9oMM0f k9DUlr3E90NRhpbynr6OEVkkgdzNcasxzKkMplVzShfCXikaXi6fkgPelwEljEhX 4VXcnsN1dJHrZUtPktlkFFXoBnxCvfbHKy0DIwrCIvB45yPGyikyKY9KZ9sOfZ3G c6HNqPEEO6TXoTk9rzMoE1vAploC7RLdfaQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1687619765; x=1687706165; bh=jUw8W/E5ZKTxIQRkRL8s1tyTfElBQNogCQV 4YwdS8E0=; b=fMBg6bpFKcmgWBXI7OG3OZWEsQMeNJTG4a/zQEDpmonmKuFOmI2 LVtoKw1Tob7pdVds2nq09P7pAHR0emqlenhlkkTP0Zh0btbmhwGaBmTJ7+zQTbnn xWYGQB70iG99U2z2O/HjcwUVbF67bcSdpNrjurxic6ZA1WbkNsHfFVUJ2f919rGR fRX5CqeR2ncxtmhqm9x0PD2HXTzSy4dp5qTrnaLnPVSFCuBkj89f5JWbFjL/RIZ1 WasdSmfFMD2kN/1MA87I2sy3MXHoAUuxu3B1MH6JDjnumzxOhHXR+XhauIxMNII4 ky15wpDk7YqFolxZElGRj+8CEpRrqelyB/w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeegjedgkeeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdgk rggtkhcuhggvihhnsggvrhhgfdcuoeiirggtkhesohiflhhfohhlihhordhorhhgqeenuc ggtffrrghtthgvrhhnpeduueeigeehffekiefhtdehiedvueffteevtefhudfguedtueei tdetgfetieeiieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpeiirggtkhesohiflhhfohhlihhordhorhhg X-ME-Proxy: Feedback-ID: i876146a2:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id C641A272007A; Sat, 24 Jun 2023 11:16:04 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: <83o7l5yt9k.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:263999 Archived-At: On Sat, Jun 24, 2023, at 7:49 AM, Eli Zaretskii wrote: >> Date: Thu, 22 Jun 2023 15:56:18 -0400 From: Zack Weinberg >> The combination of `declare-function` and >> `autoload` is intended to ensure both that the byte compiler >> understands what=E2=80=99s going on, and that `ansi-color-apply-on-re= gion` >> really is guaranteed to be available at runtime. Also, I triple- >> checked that ansi-color.el really does define this function. Why is >> the compiler still complaining? > > The problem is this part: > > (eval-when-compile > (check-declare-file byte-compile-current-file)) > > I don't understand why you are calling check-declare-file, and > moreover don't understand the argument you pass check-declare-file. > check-declare-file is a command supposed to be used interactively to > verify the 'declare' calls are valid in a given file; it shows the > results, if any, as delayed-warnings. Can you explain why you do this > in the eval-when-compile form? Because I want the declarations to be checked every time this file is byte compiled?? Maybe it makes more sense if I say it like this: I've written manual autoload forms for a bunch of functions that I *expect* to be defined in various libraries. If the guts of Emacs change and some of these functions are now defined somewhere else, I want to be notified immediately when I regenerate the .elc files for the new Emacs, not later when I try to use the commands that depend on those autoloads. Pairing each autoload with a declare-function form would achieve that ... if the byte compiler could be bothered to validate the declare- function forms. It doesn't, but check-declare does. So I kludge an invocation of check-declare into the compilation. > Remove it, and the problem will go away. So there's actually no > problem here with 'autoload' and 'declare-function'. No, there is still a problem. Let me restate the actual bug I was trying to report, so you can see it more clearly. Save the following file as test.el. ``` (declare-function ansi-color-apply-on-region "ansi-color" (begin end &optional preserve-sequences)) (declare-function dired-get-marked-files "dired" (&optional localp arg filter distinguish-one-marked er= ror)) (eval-when-compile (check-declare-file byte-compile-current-file)) (defun colorize-buffer () (interactive) (ansi-color-apply-on-region (point-min) (point-max))) (defun find-marked-files () (interactive) (mapc 'find-file (dired-get-marked-files))) ``` If you visit this file in emacs -Q and then invoke check-declare-file on it interactively, check-declare-file generates no warnings, which is correct. However, if you invoke `emacs -Q --batch -f batch-byte-compile test.el` from the shell, you will get this output: ``` uncompressing ansi-color.el.gz... uncompressing ansi-color.el.gz...done uncompressing dired.el.gz... uncompressing dired.el.gz...done In end of data: test.el:13:4: Warning: the function =E2=80=98ansi-color-apply-on-region=E2= =80=99 might not be defined at runtime. ``` "The function =E2=80=98...=E2=80=99 might not be defined" is the phrase = used by byte-compile-warn-about-unresolved-functions. It's not a check-declare diagnostic. This *must* be some form of bug, because the behavior is inconsistent: it complains about ansi-color-apply-on-region but not about dired-get-ma= rked-files. zw