Repository navigation
maths: flattening resolves notation, so an assignment-bodied macro stays a token (1 page → 8) - #545
Merged
Merged
Conversation
…GNMENT stays a token flattenMathBody expands the formula's own source so go-tex/math sees notation rather than macro names. A macro whose replacement text IS an assignment must be left for the stomach: expanding it hands back the assignment's tokens, and the engine then expands the very name the assignment was about to redefine. The self-redefining idiom makes that non-terminating. quantumarticle.cls:1108-1109 is the textbook form — nothing the first time, a separator after that: \def\@@@comma{\def\@@@comma{,}} \def\@@commaspacebefore#1{\@@@comma{}#1} Reached through \ensuremath in an author block, 2607.22466 spun \@@@comma 400 times and pushed {,} to 200 001 frames deep. Measured: pages 1 -> 8, groups still open 4 -> 0, runaway gone The Go stack named the context rather than a guess: doMath -> makeMath -> renderMathResolvingMacros -> expandMacroInMathSource -> flattenMathBody -> expandList. The guard is in the expansion path, NOT in flattenMathBody's noexp pre-pass, because the macro is not in the source being flattened — it arrives mid-expansion through etoolbox's \forlistloop, so marking names up front cannot reach it. That version was written first and measured: it changed nothing at all. Two tests, and only the first is a witness for this change: without the fix it reports the runaway. The second asserts the macro still TAKES EFFECT, because a guard that dropped the token instead of deferring it would pass the first while silently losing every separator the idiom exists to produce. Co-Authored-By: Claude Opus 5 <[email protected]>
…us demanded The first version refused to expand every macro whose body began with an assignment. The page channel liked it — 4 papers up, none down over the 154-paper list — and the equation census showed what pages cannot see: Σ dropped equations 138 -> 158 (+20) \def disappeared as a trigger (-2) \unskip disappeared (-1) \@forloop APPEARED (+23) A loop macro assigns to OTHER names and must keep expanding; only a macro that redefines ITSELF cannot be flattened. With the guard narrowed to that: Σ dropped equations 138 -> 138 (+0), no trigger gone, appeared, risen or fallen 2607.22466 still 1 page -> 8, groups 4 -> 0, runaway gone Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Oct 4, 2026
tannevaled
added a commit
that referenced
this pull request
Oct 4, 2026
The figure this README carries went stale within the hour, which is why it names the population it was measured on rather than standing alone. Re-measured on main with #543, #544 and #545: papers rendering ONE page, of the 71 the sweep flags when the series began 12 earlier today 6 now 1 (2607.05497, diagnosed in #517) #544 took three of them from 1 page to 21, 15 and 15 by making \vspace a macro again, and #545 took a fourth from 1 to 8 by leaving a self-redefining macro for the stomach. Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
flattenMathBodyexpands a formula's own source sogo-tex/mathsees notation rather than macro names. A macro whose replacement text is an assignment has to be left for the stomach: expanding it hands back the assignment's tokens, and the engine then expands the very name the assignment was about to redefine.The self-redefining idiom makes that non-terminating.
quantumarticle.cls:1108-1109is the textbook form — nothing the first time, a separator after that:Reached through
\ensuremathin an author block,2607.22466spun\@@@comma400 times and pushed{,}to 200 001 frames deep.Measured
The context was named, not guessed
GOTEX_TRACE=1gave the 127-entry chain ending\etb@forlistloop→\@@commaspacebefore→\@@@comma x268, and a Go stack gave the rest:That is why the guard sits in the expansion path and not in
flattenMathBody'snoexppre-pass: the macro is not in the source being flattened, it arrives mid-expansion through etoolbox's\forlistloop, so marking names up front cannot reach it. That version was written first and measured — it changed nothing at all, which is a refuted hypothesis rather than a near miss.Note the engine embeds the real
etoolbox.sty, so none of this is an emulation artefact.Regression control — both channels, complete
The math path touches every paper with a formula, so a page count alone is not enough: a change that traverses maths needs the equation census beside it, or a dropped formula hides inside an unchanged page total. Both run against a binary built from
main, over the 154-paper fidelity list, which contains none of the subject paper.measure mathdrop)⛔ Why the guard is on SELF-reference and not on "the body assigns"
The first version refused to expand every assignment-bodied macro. The page channel approved it — 4 papers up, none down — and the equation census showed the opposite:
A loop macro assigns to other names and must keep expanding. Only a macro that redefines itself cannot be flattened. That is the whole difference between the two versions, and the page count could not see it.
Tests
Only the first is a witness for this change: without the fix it reports the runaway. The second asserts the macro still takes effect — a guard that dropped the token instead of deferring it would pass the first test while silently losing every separator the idiom exists to produce. It passes with or without the fix, by design.
Full suite green,
go vetclean.Related: #517, #543, #544.
🤖 Generated with Claude Code