Repository navigation
engine: a runaway argument's text is eaten, not put back - #22
Merged
Merged
Conversation
Commit 01662f9 stopped a delimited-argument scan at the file-end sentinel so a runaway could no longer swallow the document after the file — a real fix, kept here. But it REINSERTED the tokens it had scanned, and that is not what TeX does. Real TeX, on exactly this shape, says Runaway argument? ! File ended while scanning use of \@tempa. The text it scanned has been EATEN as the argument; TeX never re-reads it. Putting it back makes it TYPESET, and what a runaway inside a class file scans includes the loader's own splice — \UseHook{package/…}\@Gotex@endload. A caller that has changed the catcode of \ meanwhile (beamer's line-by-line comment skipper does \@makeother\\) then prints that internal text as literal characters onto the page: a beamer talk came out as one page reading \UseHook{package/beamerbasemodes/after}…\@Gotex@endload \gotexeatdate Only the sentinel goes back now, so the file's end and the document after it still process normally — the two regression tests that came with 01662f9 (amsart's \[ patch, cip-v3's unguarded one) pass unchanged, because what they check is that the body AFTER the file survives. One visible difference on the corpus, disclosed rather than hidden: page 10 of the arXiv paper (2608.14117) re-justifies one line — same text, one space token fewer entering the paragraph. Nothing is lost; checked by rendering and by text extraction. That document is a LENIENT compile of a paper real TeX rejects at that very point, and the version that eats the runaway is the faithful one. Proof: all tests pass under -race, scripts/fidelity.sh --check is OK, and the ten TikZ documents and pages 1-9 of the paper are pixel-identical to main. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 17, 2026
v1.10.0 -> v1.12.0, which brings two library changes: linebreak #21 a break discards the whole RUN of discardables, not one glue linebreak #22 \looseness: the state is (position, line, fitness), not (position, fitness) — tex.web:16107-16114, :16716, :17197-17237 and one line of engine: `Looseness: e.namedInt("looseness")`. ## \looseness, measured looseness 0 3 lines looseness 1 4 lines A paragraph of twelve 10pt words on a 50pt measure, glue 4pt plus 8 minus 2: four to the line at 52pt shrinking, three at 38pt stretching, both decent — which is what gives the choice something to choose between. The register was declared in texparams.go and read by nothing (#754 item C, linebreak#12 item 7), so a document that set it was obeyed in silence. Three rows: the move, the control (\looseness=0 is byte-for-byte the old behaviour), and an unreachable \looseness=5 that must still set the paragraph — tex.web:17203 keeps what the final pass reached. ## ⛔ AND THE FIXTURE IS \hskip, NOT \spaceskip, FOR A REASON WORTH THE NEXT HOUR My first draft set `\spaceskip=4pt plus 8pt minus 2pt` and produced EIGHTEEN rows in which \looseness changed nothing — 6 to 15 words across three measures, flat in both directions. I was one commit from publishing that as evidence that the parameter does not reach the breaker. It was the fixture. \spaceskip is a \newskip register in this engine and NOT the base interword glue; spacefactor.go:104-109 says so in as many words. So every one of those rows was measured on spMock's own 3pt plus 1.5 space, where a three-word line needs ratio 4.7 and no second ending survives \adjdemerits. The parameter was reaching the breaker the whole time and there was nothing for it to choose. What separated it: driving the LIBRARY's fixture from inside this engine's binary (it moved, 3 -> 4), then dumping the item stream the engine hands over and seeing `w=3.00 y=1.50 z=1.00` where the source said 4/8/2. ## The bump itself is inert on every witness I have Seven documents compiled by a binary built from origin/main and one from this branch, compared BYTE FOR BYTE: prose, front, sect, floats (the four that agree page-for-page with tectonic, #813), foot (\flushbottom), foottwo ([twocolumn]), lccode (a 110pt \parbox hyphenating hard). All seven identical; suite green on all 11 packages. ⚠ "Inert on seven witnesses" is not "inert on the corpus", and the corpus is not on this machine. The discard-run change touches break_width only where a break is followed by a RUN of discardables, which synthetic prose may never build. Refs #754, Refs #813, Refs go-typeset/linebreak#21, Refs go-typeset/linebreak#22. Co-Authored-By: Claude Opus 5 <[email protected]>
tannevaled
added a commit
that referenced
this pull request
Nov 18, 2026
v1.10.0 -> v1.12.0, which brings two library changes: linebreak #21 a break discards the whole RUN of discardables, not one glue linebreak #22 \looseness: the state is (position, line, fitness), not (position, fitness) — tex.web:16107-16114, :16716, :17197-17237 and one line of engine: `Looseness: e.namedInt("looseness")`. ## \looseness, measured looseness 0 3 lines looseness 1 4 lines A paragraph of twelve 10pt words on a 50pt measure, glue 4pt plus 8 minus 2: four to the line at 52pt shrinking, three at 38pt stretching, both decent — which is what gives the choice something to choose between. The register was declared in texparams.go and read by nothing (#754 item C, linebreak#12 item 7), so a document that set it was obeyed in silence. Three rows: the move, the control (\looseness=0 is byte-for-byte the old behaviour), and an unreachable \looseness=5 that must still set the paragraph — tex.web:17203 keeps what the final pass reached. ## ⛔ AND THE FIXTURE IS \hskip, NOT \spaceskip, FOR A REASON WORTH THE NEXT HOUR My first draft set `\spaceskip=4pt plus 8pt minus 2pt` and produced EIGHTEEN rows in which \looseness changed nothing — 6 to 15 words across three measures, flat in both directions. I was one commit from publishing that as evidence that the parameter does not reach the breaker. It was the fixture. \spaceskip is a \newskip register in this engine and NOT the base interword glue; spacefactor.go:104-109 says so in as many words. So every one of those rows was measured on spMock's own 3pt plus 1.5 space, where a three-word line needs ratio 4.7 and no second ending survives \adjdemerits. The parameter was reaching the breaker the whole time and there was nothing for it to choose. What separated it: driving the LIBRARY's fixture from inside this engine's binary (it moved, 3 -> 4), then dumping the item stream the engine hands over and seeing `w=3.00 y=1.50 z=1.00` where the source said 4/8/2. ## The bump itself is inert on every witness I have Seven documents compiled by a binary built from origin/main and one from this branch, compared BYTE FOR BYTE: prose, front, sect, floats (the four that agree page-for-page with tectonic, #813), foot (\flushbottom), foottwo ([twocolumn]), lccode (a 110pt \parbox hyphenating hard). All seven identical; suite green on all 11 packages. ⚠ "Inert on seven witnesses" is not "inert on the corpus", and the corpus is not on this machine. The discard-run change touches break_width only where a break is followed by a RUN of discardables, which synthetic prose may never build. Refs #754, Refs #813, Refs go-typeset/linebreak#21, Refs go-typeset/linebreak#22. 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.
Commit 01662f9 stopped a delimited-argument scan at the file-end sentinel so a
runaway could no longer swallow the document after the file — a real fix, kept
here. But it REINSERTED the tokens it had scanned, and that is not what TeX does.
Real TeX, on exactly this shape, says
The text it scanned has been EATEN as the argument; TeX never re-reads it.
Putting it back makes it TYPESET, and what a runaway inside a class file scans
includes the loader's own splice — \UseHook{package/…}@Gotex@endload. A caller
that has changed the catcode of \ meanwhile (beamer's line-by-line comment
skipper does @makeother\) then prints that internal text as literal characters
onto the page: a beamer talk came out as one page reading
Only the sentinel goes back now, so the file's end and the document after it
still process normally — the two regression tests that came with 01662f9
(amsart's [ patch, cip-v3's unguarded one) pass unchanged, because what they
check is that the body AFTER the file survives.
One visible difference on the corpus, disclosed rather than hidden: page 10 of
the arXiv paper (2608.14117) re-justifies one line — same text, one space token
fewer entering the paragraph. Nothing is lost; checked by rendering and by text
extraction. That document is a LENIENT compile of a paper real TeX rejects at
that very point, and the version that eats the runaway is the faithful one.
Proof: all tests pass under -race, scripts/fidelity.sh --check is OK, and the ten
TikZ documents and pages 1-9 of the paper are pixel-identical to main.
🤖 Generated with Claude Code