From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar. Date: Mon, 07 Nov 2022 08:07:28 -0500 Message-ID: References: Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16928"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59057@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 07 14:08:51 2022 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 1os1ru-0004DG-Rc for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Nov 2022 14:08:51 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1os1rH-00013a-Cw; Mon, 07 Nov 2022 08:08:11 -0500 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 1os1r8-0000us-F6 for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 08:08:04 -0500 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 1os1r8-0005Jm-6M for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 08:08:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1os1r8-0001lA-1w for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 08:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 07 Nov 2022 13:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59057 X-GNU-PR-Package: emacs Original-Received: via spool by 59057-submit@debbugs.gnu.org id=B59057.16678264616734 (code B ref 59057); Mon, 07 Nov 2022 13:08:02 +0000 Original-Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 13:07:41 +0000 Original-Received: from localhost ([127.0.0.1]:33601 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os1qm-0001kY-T4 for submit@debbugs.gnu.org; Mon, 07 Nov 2022 08:07:41 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40905) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os1qk-0001kH-Ic for 59057@debbugs.gnu.org; Mon, 07 Nov 2022 08:07:39 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 73657100189; Mon, 7 Nov 2022 08:07:32 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E8F6A1000F4; Mon, 7 Nov 2022 08:07:30 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667826451; bh=vZBiHs7IJcp8MuCxqD/2DtSHY/reaQqvrzkb3o9JPjQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=YkTRMI8Sfae37Xmf5/eOYsQ378pwMknuIOBVxS4jA8uDb4QQOwahpY0yOhrb7KSXr W2lOV3TL1XkSCSDIvdeq74FTrrJ/4xTE7Tdj3HJpnBF5a9E5oQSdXmRHrGrhyxi+pY 2lwQLBarog/omdZMbd5nFYuswziKK1CLtXfXoZ1hvIYw1T8fYPxWATKpZMxkKziZLt 1o+OeIcIxvP4N1+HaPne5NGgg3iPoL3vjhmCRndPyfmTOOfJRyr1uqwcXawkTTZH4c t5SJ+YEpCz63zSHTSHSHCIfOUyY2Ke2LoM9fcAOamJ8BJSNGl3TaH3svaZH35QJHKh 2l+1nVw1DmCIg== Original-Received: from pastel (unknown [104.247.241.157]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8B44F120346; Mon, 7 Nov 2022 08:07:30 -0500 (EST) In-Reply-To: (Alan Mackenzie's message of "Sat, 5 Nov 2022 18:46:49 +0000") 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:247281 Archived-At: > (defmacro acm-defvar (var) > `(eval-when-compile > ; (when (version-check) > (defvar ,var) > (setq ,var emacs-major-version) > ; ) > )) (defvar VAR) does not "create a variable". It just "locally" declares that this identifier should use dynamic scoping when binding a variable. Before the commit you mentioned, the above (defvar ,var) would sometimes incorrectly escape its `when` subexpression and affect subsequent code, which is why in the past the presence of `when` did not make much difference whereas it now does. Note also that for the same reason the above should arguably never work at all since the effect of (defvar ,var) should not escape the `eval-when-compile` subexpression. A lot of code relies on this misbehavior, tho, so we still support it. But the better way to write the above code is: (defmacro acm-defvar (var) `(progn (defvar ,var) (eval-when-compile (when (version-check) (setq ,var emacs-major-version))))) > This bug doesn't occur on Emacs 28. > I have a feeling it was introduced into Emacs 29 very recently. The Emacs-28 behavior was a misbehavior, which got fixed accidentally recently :-) Stefan