Repository navigation
compiler: tabbing controls and escaped \& keep their identity through a macro (#760 sites 3 and 4) - #761
Merged
Conversation
… a macro (#760) What changed: Two more instances of the #756 pattern — deciding what a token *means* by comparing its source-span width to a literal constant. A token copied out of a macro's replacement text carries the *invocation's* span, so the width test was really measuring how long a name the user happened to give the macro. - `parser::is_tabbing_control` (`\=` `\>` `\<` `\+` `\-` in `tabbing`) now takes `maps_to_invocation`/`definition` and measures the token's own source bytes, exactly as `control_symbol_kern` already does for `\,`. Both callers pass the provenance through. - `parser::tabular::is_escaped_ampersand`, a new helper replacing the inline `!input.maps_to_invocation && span.end - span.start == 2` guard, does the same for the escaped `\&` that must not open the next entry. Expanded text with no definition bytes cannot prove it spells a control symbol, so it falls back to the visible reading: `\=`-family tokens are typeset and `&` separates. The failure ran in both directions at both sites, and the second direction is silent — a wrong glyph is visible, a missing one is not: tabbing \= via 3-byte macro \ts before [xx][=][yy] after [xx][yy] tabbing literal = via 2-byte \q before [xx][yy] after [xx][=][yy] tabular a\am b, \newcommand{\am}{\&} before two cells after one cell "a & b" The `\&` case is the worst of the three: it corrupts a table's structure, not just its spacing, shifting every later cell in the row. No corpus change is expected — the render route builds against the frozen vendor/compiler, so this is invisible until the re-pin (#711). What was run: cargo test -p flashtex-compiler (crates/compiler, full) 77 suites, "test result: ok" in every one, 918 passed, 0 failed cargo test (crates/bridge, full) 170 passed, 0 failed Reverting only the two source hunks (tests kept) fails exactly the four new regression tests and no others: tabbing::tab_stop_reached_through_a_long_macro_still_sets_a_stop FAILED tabbing::tab_jump_reached_through_a_long_macro_still_jumps FAILED tabbing::a_plain_character_from_a_two_byte_macro_is_not_a_tabbing_control FAILED tabular::tests::escaped_ampersand_from_a_macro_is_text_not_a_column_break FAILED -> "extra alignment tab: this row has more entries than the 2 columns" The four guard tests (running text, literal `\=`, literal `a&b` and `a\&b`, and a genuine `&` reached through a two-byte macro) pass both with and without the fix, which is what makes them guards. Next step: sites 1 and 2 of #760 (math.rs:1586, math.rs:2998) are held by daniel-muse-lead-2 and additionally need provenance threaded into the math token stream; math.rs is untouched here. Implementation-Agent: claude-opus-5 subagent of daniel-parent Commit-Executor: daniel-parent subagent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
d-q222
added a commit
that referenced
this pull request
Sep 17, 2026
#784 All eight independently reviewed APPROVE. Batch verification: compiler 935/0, render-pipeline 487/0, perf-bench 14/0, perf gate OK (270 metrics, no regression), swift build --build-tests OK, CompletionTests 29/0. Commit-Executor: daniel-parent Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
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.
What
Fixes sites 3 and 4 of #760 — two more instances of the #756 pattern:
deciding what a token means by comparing its source-span byte width to a
literal constant. A token copied out of a macro's replacement text carries the
invocation's span, so the width test was really measuring how long a name
the user happened to give the macro.
parser::is_tabbing_control(parser.rs:10320) —\=\>\<\+\-in
tabbing. Now takesmaps_to_invocation/definitionand measures thetoken's own source bytes. Both callers pass the provenance through.
parser::tabular::is_escaped_ampersand(parser/tabular.rs:535) — a newhelper replacing the inline
!input.maps_to_invocation && span.end - span.start == 2guard, doing the same for the escaped
\&that must not open the next entry.Both use the idiom
control_symbol_kern(parser.rs:10329) already proves onthe same characters:
Expanded text with no definition bytes cannot prove it spells a control
symbol, so it falls back to the visible reading:
\=-family tokens are typesetand
&separates. Nothing is invented here; the mechanism is the onecontrol_symbol_kern's doc comment already describes.math.rsis untouched — sites 1 and 2 (math.rs:1586,math.rs:2998) areheld by
daniel-muse-lead-2and additionally need provenance threaded into themath token stream.
Why
The failure runs in both directions at both sites, and the second direction
is the one nobody noticed: a wrong glyph is visible, a missing one is not.
Measured through the full compile path (
protocol::handle_line), every emitteditem's
text:tabbing\=via 3-byte macro\ts[xx][=][yy]— prints a literal=, sets no tab stop[xx][yy]tabbingliteral=via 2-byte macro\q[xx][yy]— the=vanished[xx][=][yy]\qin running text (control)[xx][=][yy][xx][=][yy]— unchangedtabular{ll}a\am b,\newcommand{\am}{\&}a&ba & bThe
\&case is the worst of #760's four: an escaped ampersand arriving from amacro silently becomes a column break, so every later cell in the row shifts.
That corrupts a table's structure, not just its spacing — and it reported
extra alignment tab: this row has more entries than the 2 columns of the tableon a table that had exactly two.No corpus change is expected. The render route builds against the frozen
vendor/compiler, so this is invisible until the re-pin (#711); it is proved inthe compiler's own tests instead.
vendor/is untouched.Overlap check
python3 scripts/coord.py claims— onlyGH-F12-FLOAT-TABULAR(this lane'sother task) was held; no adjacent
GH-760-*claim. ClaimedGH-760-TABBING-TABULAR-SPAN.gh pr list --state all --searchfor760,tabbing,maps_to_invocation—nothing open against either site. compiler: tabbing environment (\= \> \\ \kill) (GH-TABBING) #551/integration: comment environment and tabbing (#553, #551) #642 shipped
tabbingitself; compiler: punctuation after a style group survives macro expansion (GH-MACRO-BODY-COMMA) #576fixed a neighbouring macro-body case in a different code path.
math.rsdeliberately left todaniel-muse-lead-2(compiler: \, inside a macro body emits a literal comma — math spacing commands are detected by source-span byte length #756 and site 2), sothere is no file-level conflict.
Test results
Reverting only the two source hunks and keeping the tests fails exactly the
four new regression tests and nothing else:
The four guard tests pass both with and without the fix, which is what makes
them guards — they pin the ways an over-broad fix would break things:
the_same_macro_prints_the_character_in_running_text_and_in_tabbing— runningtext is unaffected;
a_literal_tabbing_control_is_unaffected— the ordinary non-macro\=path;a_real_ampersand_from_a_two_byte_macro_still_breaks_the_column— a genuinealignment tab still separates when it arrives through a macro of exactly the
shape the old width test keyed on;
literal_ampersands_keep_their_meanings— barea&bstill makes two cells,literal
a\&bstill makes one.cargo fmt --checkon the four touched files reports nothing on any added line(the crate carries pre-existing repo-wide rustfmt drift across ~65 files).
Not done
math.rs:1586math spacing = compiler: \, inside a macro body emits a literal comma — math spacing commands are detected by source-span byte length #756, andmath.rs:2998\left\|/\right\|) are unfixed and still reproduce. They areowned by
daniel-muse-lead-2and need provenance threaded into the math tokenstream, which is a larger change;
math.rswas deliberately not opened.frozen
vendor/compileruntil re-pin readiness: the compiler vendor re-pin is now one step (runbook + gated pipeline arms; fixes 13 red tests on main) #711.🤖 Generated with Claude Code
https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz