From: Dave Goel <deego3@gmail.com>
To: emacs-devel@gnu.org, Dave Goel <deego3@gmail.com>
Subject: An MRE or other hints for this macro / dynamic scoping bug?
Date: Sun, 5 Nov 2023 14:57:42 -0500 [thread overview]
Message-ID: <CAOCW0Djn3w_0qEXyesoErmEC2-S3KFgt+DxpkJFBhjEPDRQRkw@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1309 bytes --]
Hey Emacsers,
I'm likely losing my mind. Is this not a bug, below?
I tried discussing on #emacs first, and then reported (a slightly more
complex version). But, it's perhaps not obvious, and it was suggested I
try to produce a simpler example.
I realize I should have discussed it here first, before reporting it. A
discussion here would probably produce a much better bug report in any
case.
Do you guys see an obvious bug here? Any simpler versions you can think
of? Any hints where the bug could lie?
Basically, I define a macro that hardcodes the value of our variable ii
that existed before the macro definition.
And, then try to use it.
(progn
(setq lexical-binding nil)
(dotimes (ii 10)
(defmacro mac ()
`(message "%S" ,ii)
)
(mac)))
That's the code.
Eval it once. Works.
Eval it again. Works.
Eval it the third time. Debugger entered. Tested in emacs -Q in 28 and 29.
[[a]]
In fact, before you eval it the third time, if you change ii to jj, it
still complains about ii. [[b]]
Bugs are the behaviors (a) and (b) above.
The macro expands to (list 'message "%S" ii). That should have worked,
right? Because ii was already set at the time of definition?
Here's the debugger behavior -
Debugger entered--Lisp error: (void-variable ii)
(list 'message "%S" ii)
[-- Attachment #2: Type: text/html, Size: 2064 bytes --]
next reply other threads:[~2023-11-05 19:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-05 19:57 Dave Goel [this message]
2023-11-05 20:04 ` An MRE or other hints for this macro / dynamic scoping bug? Andreas Schwab
2023-11-05 20:12 ` Dave Goel
2023-11-05 20:50 ` Andreas Schwab
2023-11-05 20:07 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAOCW0Djn3w_0qEXyesoErmEC2-S3KFgt+DxpkJFBhjEPDRQRkw@mail.gmail.com \
--to=deego3@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).