Skip to content

Keep pretty-printer character variable local - #22

Merged
andremm merged 2 commits into
andremm:mainfrom
dajiaohuang:fix-pretty-printer-global-char
Nov 13, 2026
Merged

andremm merged 2 commits into
andremm:mainfrom
dajiaohuang:fix-pretty-printer-global-char

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Calling the documented pp.tostring API on an AST containing a string assigns each byte to the global char, overwriting a caller's existing value or creating a new global.

Make the loop variable local. The standalone pretty-printer regression checks existing and absent global values; as requested in review, test.lua now runs it near the end, announces the section, and keeps its shebang first.

Validation: the earlier revision's isolated embedded Lua 5.1, 5.3 and 5.4 regression passed. For the current revision, git diff --check passed; native Lua and LPegLabel are unavailable here, so the full suite and runtime matrix remain unverified.

Comment thread test.lua Outdated
@@ -1,3 +1,5 @@
dofile("test-pp.lua")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to move this to the end of the file. Perhaps before the last OK print and maybe add a print saying you are testing the pretty printer.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to add the pretty printer test code at the end of this test file.

@andremm
andremm merged commit 1d83a73 into andremm:main Nov 13, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants