* An MRE or other hints for this macro / dynamic scoping bug? @ 2023-11-05 19:57 Dave Goel 2023-11-05 20:04 ` Andreas Schwab 2023-11-05 20:07 ` Stefan Kangas 0 siblings, 2 replies; 5+ messages in thread From: Dave Goel @ 2023-11-05 19:57 UTC (permalink / raw) To: emacs-devel, Dave Goel [-- 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 --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: An MRE or other hints for this macro / dynamic scoping bug? 2023-11-05 19:57 An MRE or other hints for this macro / dynamic scoping bug? Dave Goel @ 2023-11-05 20:04 ` Andreas Schwab 2023-11-05 20:12 ` Dave Goel 2023-11-05 20:07 ` Stefan Kangas 1 sibling, 1 reply; 5+ messages in thread From: Andreas Schwab @ 2023-11-05 20:04 UTC (permalink / raw) To: Dave Goel; +Cc: emacs-devel How do you eval it? -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: An MRE or other hints for this macro / dynamic scoping bug? 2023-11-05 20:04 ` Andreas Schwab @ 2023-11-05 20:12 ` Dave Goel 2023-11-05 20:50 ` Andreas Schwab 0 siblings, 1 reply; 5+ messages in thread From: Dave Goel @ 2023-11-05 20:12 UTC (permalink / raw) To: Andreas Schwab, Dave Goel; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 436 bytes --] C-x C-e at the end of the block of the code. Also, regarding bug (b) - we changed every instance of ii to jj. Yet it complained about a ghost ii. On Sun, Nov 5, 2023 at 3:04 PM Andreas Schwab <schwab@linux-m68k.org> wrote: > How do you eval it? > > -- > Andreas Schwab, schwab@linux-m68k.org > GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 > "And now for something completely different." > [-- Attachment #2: Type: text/html, Size: 983 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: An MRE or other hints for this macro / dynamic scoping bug? 2023-11-05 20:12 ` Dave Goel @ 2023-11-05 20:50 ` Andreas Schwab 0 siblings, 0 replies; 5+ messages in thread From: Andreas Schwab @ 2023-11-05 20:50 UTC (permalink / raw) To: Dave Goel; +Cc: emacs-devel Use M-x ielm instead. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: An MRE or other hints for this macro / dynamic scoping bug? 2023-11-05 19:57 An MRE or other hints for this macro / dynamic scoping bug? Dave Goel 2023-11-05 20:04 ` Andreas Schwab @ 2023-11-05 20:07 ` Stefan Kangas 1 sibling, 0 replies; 5+ messages in thread From: Stefan Kangas @ 2023-11-05 20:07 UTC (permalink / raw) To: Dave Goel, emacs-devel Dave Goel <deego3@gmail.com> writes: > 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. Actually, a bug report is much better so that we can track the progress. In this case, we already have Bug#66940, so I recommend reporting your findings there. A new thread on emacs-devel at this point will just make the discussion harder to follow. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-05 20:50 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-11-05 19:57 An MRE or other hints for this macro / dynamic scoping bug? Dave Goel 2023-11-05 20:04 ` Andreas Schwab 2023-11-05 20:12 ` Dave Goel 2023-11-05 20:50 ` Andreas Schwab 2023-11-05 20:07 ` Stefan Kangas
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).