From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#46387: 28.0.50; Compiled code making a variable dynamic stopped working Date: Tue, 9 Feb 2021 11:32:58 +0100 Message-ID: References: <87h7mm79ij.fsf@web.de> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5195"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 46387@debbugs.gnu.org, monnier@iro.umontreal.ca To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 09 11:34:39 2021 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 1l9QLv-0001Ee-8y for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 11:34:39 +0100 Original-Received: from localhost ([::1]:40592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9QLu-0004du-7g for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Feb 2021 05:34:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QLL-0004Bo-MO for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 05:34:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l9QLL-000547-E7 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 05:34:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1l9QLK-0000MU-B6 for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 05:34:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Feb 2021 10:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46387 X-GNU-PR-Package: emacs X-Debbugs-Original-Cc: bug-gnu-emacs@gnu.org, Stefan Monnier Original-Received: via spool by submit@debbugs.gnu.org id=B.16128668001343 (code B ref -1); Tue, 09 Feb 2021 10:34:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Feb 2021 10:33:20 +0000 Original-Received: from localhost ([127.0.0.1]:52752 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9QKe-0000La-9E for submit@debbugs.gnu.org; Tue, 09 Feb 2021 05:33:20 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:38814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1l9QKc-0000LS-2i for submit@debbugs.gnu.org; Tue, 09 Feb 2021 05:33:19 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56854) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QKZ-00038E-Pa for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 05:33:17 -0500 Original-Received: from mail1475c50.megamailservers.eu ([91.136.14.75]:60874 helo=mail118c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9QKT-0004dz-UI for bug-gnu-emacs@gnu.org; Tue, 09 Feb 2021 05:33:15 -0500 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1612866781; bh=xvqELYBN9TYUMSCXbDve3HYD8HCpuTSZlR82oT1RBsk=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=ctN5TdLxXZTvXDJABVwTHDFbQOdMWY382PH8S8aAqqoJIgSGQQlQ8sdQ379gqglAA 4AAtIFflva42NcvGxgkvZVnM6nmBWGHM9CE0FgeXuhr9jf4rr3dUwLcrE3p29mrjS7 0NxDhslG/hGRJ5iBQlvztlquCgdHnCN6q6amnde0= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail118c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 119AWxbM021342; Tue, 9 Feb 2021 10:33:00 +0000 In-Reply-To: <87h7mm79ij.fsf@web.de> X-Mailer: Apple Mail (2.3445.104.17) X-CTCH-RefID: str=0001.0A742F24.602264DD.0029, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=HYRqsRM8 c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=kj9zAlcOel0A:10 a=M51BFTxLslgA:10 a=spfw7PUuAAAA:8 a=cls0VBjIcQtipXP9x_gA:9 a=CjuIK1q_8ugA:10 X-Origin-Country: SE Received-SPF: softfail client-ip=91.136.14.75; envelope-from=mattiase@acm.org; helo=mail118c50.megamailservers.eu X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action 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" Xref: news.gmane.io gmane.emacs.bugs:199680 Archived-At: 8 feb. 2021 kl. 18.29 skrev Michael Heerdegen = : > the latest changes in byte-opt.el seem to have broken some of my code. > It worked since yesterday, and it still works when interpreted, but = the > compiled code raises this error today: Intereresting, thank you! And sorry about that. > (with-suppressed-warnings ((lexical date original-date number)) > (defvar date) > (defvar original-date) > (defvar number)) There's a lack of clarity regarding the exact semantics of local = `defvar`. The manual says that its effect is confined to the current = lexical scope, but what exactly does that mean? As it turns out, parts of the implementation have different opinions = about that. As you observed, the recently added optimisation on master = takes a strict syntactic view: even a `progn` is a lexical scope, and = `with-suppressed-warnings` wraps its body in a `progn`; thus your = `defvar` declarations have no effect outside that construct. However, the interpreter is at the other extreme end and takes a very = dynamic view. For example: (defun f (x) (if x (defvar my-var)) (let ((my-var 17)) (do-something))) Here, whether my-var is a lexical or dynamic variable depends on the = argument x! The compiler unsurprisingly is of more static persuasion but = sadly hazy on the details. For example, the above function is compiled = (in Emacs 27) with my-var lexically bound, but if we say (defun g () (if (=3D 1 2) (defvar my-var)) (let ((my-var 17)) (do-something))) then my-var becomes dynamic. Ouch. While we ponder over the problem, you may try separate = with-suppressed-warnings for each variable. Ie, (with-suppressed-warnings ((lexical date)) (defvar date)) (with-suppressed-warnings ((lexical original-date)) (defvar original-date)) (with-suppressed-warnings ((lexical number)) (defvar number)) hoping that each single-expression `progn` will rapidly decay into its = confined expression (a defvar) and thus will be syntactically in the = right lexical scope. (Stefan, it looks like your latest Gnus patch may fall in the same trap. = Or?)