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 16:29:15 -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="33663"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) 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 22:30:15 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 1os9h8-0008VJ-Nb for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 07 Nov 2022 22:30:14 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1os9gx-0003TH-VF; Mon, 07 Nov 2022 16:30:03 -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 1os9gw-0003Sa-IH for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 16:30:02 -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 1os9gw-0005pr-84 for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 16:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1os9gv-0002TA-U8 for bug-gnu-emacs@gnu.org; Mon, 07 Nov 2022 16:30:01 -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 21:30:01 +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.16678565719429 (code B ref 59057); Mon, 07 Nov 2022 21:30:01 +0000 Original-Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 21:29:31 +0000 Original-Received: from localhost ([127.0.0.1]:35572 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os9gQ-0002S0-P6 for submit@debbugs.gnu.org; Mon, 07 Nov 2022 16:29:31 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1os9gP-0002Rn-24 for 59057@debbugs.gnu.org; Mon, 07 Nov 2022 16:29:29 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 295258024C; Mon, 7 Nov 2022 16:29:23 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9AB9A8043D; Mon, 7 Nov 2022 16:29:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667856561; bh=K17qnOXenix7GRmIRhkTFgNaxryQHBsWkqVD7d1HX38=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=KpoUjruTvcrKUXNKuo2Cv1L+3sZJ6C4EVLGKz/4MXR3VrEvf+b/ZBShSrse5Ndh2l XT9xwfsMAihspOncXFFWfLjyNr1E7mJ5pl/ynDeY/27VytdwBkonnTpyQraIRMLbcL Z/AiiF8Fn3t0P3KCP3I07GWJRJBLQl6/76XoKPlWr2BtI/32dvDjWVzG5/sD4yY5B4 9Eev2xhPhkoSxRfw5cQfGfbdK7qyS6H2fSr2IPtDVakKHUYedWohOB60cr7zgWzX5R PAirxK3S20aXmubyIX9sEGVngTqtCUtAODT+L7nXlDjkPYXhtoGpcKTUg9EOibcLpW xCyvYO5zQko5Q== Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5AB24120F9E; Mon, 7 Nov 2022 16:29:21 -0500 (EST) In-Reply-To: (Alan Mackenzie's message of "Mon, 7 Nov 2022 20:20:20 +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:247301 Archived-At: >> (defvar VAR) does not "create a variable". > > According to both its doc string and the Elisp manual it does. Where? I'm talking specifically about (defvar VAR) not about `defvar` in general. >> It just "locally" declares that this identifier should use dynamic >> scoping when binding a variable. > Why "locally"? There's just one obarray involved, which is global. No, we want to allow `defvar` to have a lexically-local effect. >> 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))))) > > There are workarounds, yes. But surely it would be better to fix the > bug. It's not a workaround. It's how the programmers say whether they want the (defvar ,var) declaration to affect all the rest of the code or only the code within the `when`. Why put the (defvar ,var) within the `when` if not to limit its scope? Stefan