From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dave Goel Newsgroups: gmane.emacs.bugs Subject: bug#66940: Dynamic scoping is all weird now? Date: Sun, 5 Nov 2023 15:21:25 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000004485c06096d7c22" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4002"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 66940@debbugs.gnu.org To: Gerd =?UTF-8?Q?M=C3=B6llmann?= , Dave Goel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Nov 05 21:22:40 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 1qzjdo-0000rZ-Hu for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 05 Nov 2023 21:22:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qzjda-0001T5-4H; Sun, 05 Nov 2023 15:22:26 -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 1qzjdZ-0001Sr-EN for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 15:22:25 -0500 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 1qzjdZ-00047I-4s for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 15:22:25 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qzje9-00065z-Ob for bug-gnu-emacs@gnu.org; Sun, 05 Nov 2023 15:23:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dave Goel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 05 Nov 2023 20:23:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66940 X-GNU-PR-Package: emacs Original-Received: via spool by 66940-submit@debbugs.gnu.org id=B66940.169921574323383 (code B ref 66940); Sun, 05 Nov 2023 20:23:01 +0000 Original-Received: (at 66940) by debbugs.gnu.org; 5 Nov 2023 20:22:23 +0000 Original-Received: from localhost ([127.0.0.1]:38252 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzjdW-000655-Iu for submit@debbugs.gnu.org; Sun, 05 Nov 2023 15:22:22 -0500 Original-Received: from mail-il1-x12f.google.com ([2607:f8b0:4864:20::12f]:56628) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qzjdU-00064p-2j for 66940@debbugs.gnu.org; Sun, 05 Nov 2023 15:22:21 -0500 Original-Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-3575287211bso13619065ab.1 for <66940@debbugs.gnu.org>; Sun, 05 Nov 2023 12:21:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1699215697; x=1699820497; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=hYQd+clV/FzIQ396akG/KIUgNRTH9XXG6cxXom5ZP5c=; b=eDD7ZHK3GTkFVOd1KLtmNnBE4Hh1Y6AH6vNVG9bxUY9zzU5on0hzjuv8mJC12VwUSr CaY4KGehlznOOTZ2jgOjJIiaMwR9tLaxPK1u/Zla13mHzoRAtrXxefPFkLbrveLmY3vw 8L1RDn6SeclX9EFixZkkC44mn0m1lhDNLdsgK6NSlxHG3izZiwVSWE4lCfLrSeeClbsw 4VY6yuaWXmyIk/hJQyPhNSvZGGmMlofQzkvZn0tsI43wsLfZpSIAuXuVgWkzY/7cpF3n bRkEqFlAyqa1jHz9urQ4ENPuMDSg5Wmn9qLSyXOTG0sNB4M3w0c6yd5n/jvX5nDyH2u0 TfKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699215697; x=1699820497; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hYQd+clV/FzIQ396akG/KIUgNRTH9XXG6cxXom5ZP5c=; b=MWVdE0TkoHcOAaVJziXoH1DwnBbsTPtQXfmFUzEgtKab1Plc4gDl5VuQVYx6iU3IGr Wa2qUBC+ZsiNd8KLgIl5HR5/qmHC/Z8te7LI4OSLrh9UlbRHW8mhp5rhj6eosqy3PJvw cPEZbcP6Apg7UoEcXMxYvSacmj7pd5W0WgyzHV9BwFYnNmje3f7IPNirJqJp+mPMlFM4 ZALiBTBaAa8x0wrXfvcWo9jKqWpoyOwk5mMEC/rjqjLXHvNjEtLMlA2OzN92bfdhfpHy Eqm0F6kTIYz3NVJ+fAzRVciqJB+u/t5zSnf9N9owjyKGm91crfT96ty1v8DRtnXvGy9c N6FQ== X-Gm-Message-State: AOJu0Yw66z+pTo2aB6FwqRCHnCq+1hpEYpprOtbC9wZkRNENmMXT3q/r E0lVLMkUTbyaFaiEb54kYv8MnCTASsmXxCAgV0250WAyJSU= X-Google-Smtp-Source: AGHT+IEGEXwXkGu/DR7zcUGUJ2Gp2UwRNFLdUwNCiip681bccUJS7UqQRoRMAuxtcSvzVMjYtZfGNbkrYc9l1zbLIoY= X-Received: by 2002:a92:c26a:0:b0:357:a337:b12f with SMTP id h10-20020a92c26a000000b00357a337b12fmr35017288ild.12.1699215697002; Sun, 05 Nov 2023 12:21:37 -0800 (PST) In-Reply-To: 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:273843 Archived-At: --00000000000004485c06096d7c22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Here's the simplest MRE I have so far - (progn (setq lexical-binding nil) (let ((ii 1)) (defmacro mac () `(message "%S" ,ii) ) (mac))) Eval it three times, using C-x C-e. Error on the third time. (Following the prior response, I figured I will discuss on devel first to confirm before officially reporting it, but was kinda directed back here.) On Sun, Nov 5, 2023 at 2:07=E2=80=AFPM Dave Goel wrote: > Gerd, > > Ok. > > I hope this bugreport is clearer - > > Here's some code. > > The variable ii is clearly set every time mac was defined OR called. > > backquote should expand, and mac should have read its content as (list > 'message "%S" ii). > > > > > (progn > (setq lexical-binding nil) > > (dotimes (ii 10) > (defmacro mac () > `(message "%S" ,ii) > ) > (let > ((old_ii ii)) > (setq ii 33) > (mac) > (setq ii old_ii) > ))) > > > You eval this code once. It works. > You eval this again. It works. > The third time, though, it lands you in the debugger. The very same code. > Why the third time? And, why the debugger? ii is well set every time it = is > used. > > That was bug (b). That's clearly an emacs bug? > > > Here's (c) - > > The third time, change every "ii" to "var" ,and change every "old_ii" to > "old_var". > And, evaluate it. > We still get the very same error, but the error involves ii, not var. The > code we are defining and eval'ing has no "ii" whatsoever. It should have > forgotten the old mac that involved ii. We defined a new mac involving > "var." > > >> >> --00000000000004485c06096d7c22 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Here's the simplest MRE I have so far - =

(progn
=C2=A0 (setq lexical-binding nil)

=C2=A0 (let ((ii= 1))
=C2=A0 =C2=A0 (defmacro mac ()
=C2=A0 =C2=A0 =C2=A0 `(message &q= uot;%S" ,ii)
=C2=A0 =C2=A0 =C2=A0 )
=C2=A0 =C2=A0 (mac)))

Eval it three times, using C-x C-e.
Error on the third time.
<= div class=3D"gmail_default" style=3D"font-family:trebuchet ms,sans-serif;co= lor:#0000ff">
(Following the=C2=A0prior response, I = figured I will discuss on devel first to confirm before officially reportin= g it, but was kinda directed back here.)



On Sun, Nov 5, 2023 at 2:07=E2=80=AFPM Dave Goel <deego3@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">
Gerd,

Ok.

I hope this= bugreport is clearer -

Here's some code.

The variable i= i is clearly set every time mac was defined OR called.

backquote sho= uld expand, and mac should have read its content as (list 'message &quo= t;%S" ii).




(progn
=C2=A0 (setq lexical-binding n= il)

=C2=A0 (dotimes (ii 10)
=C2=A0 =C2=A0 (defmacro mac ()
=C2= =A0 =C2=A0 =C2=A0 `(message "%S" ,ii)
=C2=A0 =C2=A0 =C2=A0 )=C2=A0 =C2=A0 (let
=C2=A0 =C2=A0 =C2=A0 =C2=A0 ((old_ii ii))
=C2= =A0 =C2=A0 =C2=A0 (setq ii 33)
=C2=A0 =C2=A0 =C2=A0 (mac)
=C2=A0 =C2= =A0 =C2=A0 (setq ii old_ii)
=C2=A0 =C2=A0 =C2=A0 )))


You eval= this code once. It works.
You eval this again. It works.
The third t= ime, though, it lands you in the debugger. The very same code. Why the thir= d time? And, why the debugger?=C2=A0 ii is well set every time it is used.<= br>
That was bug (b). That's clearly an emacs bug?


Here&= #39;s (c) -

The third time, change every "ii" to "va= r" ,and change every "old_ii" to "old_var".
And= , evaluate it.
We still get the very same error, but the error involves = ii, not var. The code we are defining and eval'ing has no "ii"= ; whatsoever. It should have forgotten the old mac that involved ii. We def= ined a new mac involving "var."



--00000000000004485c06096d7c22--