From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#73725: Master: Wrong position for byte compiler warning message. Date: Tue, 22 Oct 2024 21:19:13 +0000 Message-ID: References: <8A05D4D2-C77B-4089-B82C-4DB3E88F1276@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9232"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73746@debbugs.gnu.org, acm@muc.de, Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= , 73725@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 22 23:19:55 2024 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 1t3MIF-0002Ek-9r for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Oct 2024 23:19:55 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t3MHw-0002cy-Hn; Tue, 22 Oct 2024 17:19:36 -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 1t3MHu-0002cX-Bo for bug-gnu-emacs@gnu.org; Tue, 22 Oct 2024 17:19:34 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t3MHu-0004op-3C for bug-gnu-emacs@gnu.org; Tue, 22 Oct 2024 17:19:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=From:In-Reply-To:MIME-Version:References:Date:To:Subject; bh=HKKa8mWFQk8wMNpAVye5r1ekhq3WrJZ2M6zf+6OsGYE=; b=U/Gn2Fa7kAMy+oz6jxaTwh70LkW2EsEGw7p5GqXynAXwmZKmg50kIEBMQKr9HrcQkAUX7Z7lKCJ0aEgl9dpQk27e9m2q19qbAMM0pU+MxTKnlKlMCXkxkZuHfsxAhfOFQ+RcKH/iTgZYFMCO6Kb4mUlJHTqzp2/S0IzD1NDtpQ8X8TpvmHjhdrdZ1l0TnuwX4UyyL7hpiSZSW1ONLGpamNNPXXc5R2NEpvv9gD4OMc4saUUCpE6R2wkQefgoDnGrTKpEEgdy/rkjjwsKWCOE/hO8flfO8FLSFqWl/ROT7+ea+05bfvYm2gS0ufy6Hd80Nv4CJQufJxRtPI4ckQLttQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t3MIM-0000Jy-1x for bug-gnu-emacs@gnu.org; Tue, 22 Oct 2024 17:20:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Oct 2024 21:20:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73725 X-GNU-PR-Package: emacs Original-Received: via spool by 73725-submit@debbugs.gnu.org id=B73725.17296319981220 (code B ref 73725); Tue, 22 Oct 2024 21:20:01 +0000 Original-Received: (at 73725) by debbugs.gnu.org; 22 Oct 2024 21:19:58 +0000 Original-Received: from localhost ([127.0.0.1]:57654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t3MII-0000Jb-3T for submit@debbugs.gnu.org; Tue, 22 Oct 2024 17:19:58 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:59643) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t3MIE-0000Iy-02 for 73725@debbugs.gnu.org; Tue, 22 Oct 2024 17:19:54 -0400 Original-Received: (qmail 57441 invoked by uid 3782); 22 Oct 2024 23:19:14 +0200 Original-Received: from muc.de (p4fe15a4c.dip0.t-ipconnect.de [79.225.90.76]) (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 22 Oct 2024 23:19:13 +0200 Original-Received: (qmail 9293 invoked by uid 1000); 22 Oct 2024 21:19:13 -0000 Content-Disposition: inline In-Reply-To: X-Submission-Agent: TMDA/1.3.x (Ph3nix) X-Primary-Address: acm@muc.de 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:294126 Archived-At: Hello, Stefan. On Tue, Oct 22, 2024 at 09:33:02 -0400, Stefan Monnier wrote: [ .... ] > >> > (defun macroexp-macroexpand (form env) > >> > "Like `macroexpand' but checking obsolescence." > >> > (let* ((macroexpand-all-environment env) > >> > new-form) > >> > + (macroexp-preserve-posification > >> > + form > >> > (while (not (eq form (setq new-form (macroexpand-1 form env)))) > >> > + (setq macroexpanded t) > >> > (let ((fun (car-safe form))) > >> > (setq form > >> > (if (and fun (symbolp fun) > >> This `(setq macroexpanded t)` looks like some leftover code, at least > >> I couldn't find this var declared or used elsewhere. > > I remember removing it, but can't remember exactly why. When I byte > > compile the code, I don't get an undeclared variable warning for it, for > > some reason. > [ Interesting. I'll try to remember to track down this sucker later. ] I think I understand this, now. It's a "use-mention" confusion. ;-). When macroexp-macroexpand is getting compiled, the compiler calls (the loaded or compiled version of) that function. Running the function `setq's macroexpanded, hence binds it. Later, the compiler calls byte-compile-free-vars-warn. This fails to do anything because of the clause (boundp var) in the enclosing `unless' form. VAR aka macroexpanded is indeed now bound, see previous paragraph. I'm not sure there's much that can be done about this "bug". I'm even less sure that it's worth the trouble. Maybe there could be a more rigorous check of the variable's existence than (boundp var). But, as I say, it's likely not worth the trouble. Maybe there are other free variables hiding in the compiler, though. What do you think? > Stefan -- Alan Mackenzie (Nuremberg, Germany).