Repository navigation
A \hyphenation entry does not escape \lefthyphenmin and \righthyphenmin (tex.web:18159-18160) - #809
Merged
Merged
Conversation
…in (tex.web:18159-18160)
tex.web:18145-18160 is one block. The exception table is consulted FIRST and a
hit does `goto found` -- to the SAME label the pattern scan falls through to --
and `found` is where the limits are imposed:
found: for j:=0 to l_hyf-1 do hyf[j]:=0;
for j:=0 to r_hyf-1 do hyf[hn-j]:=0
So \hyphenation{} says where a break MAY go, not that one must, and
\lefthyphenmin/\righthyphenmin refuse an exception's breaks exactly as they
refuse a pattern's.
⭐ THE COMMENT WAS RIGHT AND THE CODE WAS WRONG, which is the harder way round to
find. hyphexception.go's header has said "\lefthyphenmin and \righthyphenmin
still apply, as they do to any word" since it was written, and nothing did it:
lookup returned the entry's breaks and hyphenation.go wrote them straight into
breakAfter. A reader checking the rule meets it stated correctly and moves on.
The pattern path was never affected -- Hyphenator.Points applies the minima
itself (`for t := h.lmin; t <= L-h.rmin`), which is why only exceptions escaped.
clipToMins is in hyphexception.go, where the exception semantics live.
⛔ IT IS APPLIED WHEN THE WORD IS HYPHENATED, NOT WHEN THE ENTRY IS RECORDED. TeX
imposes the limits in `hyphenate`, and a document may write \hyphenation{} in a
package and set \lefthyphenmin afterwards, or change it per language
mid-document; clipping at `add` time would freeze whichever value happened to be
in force when the entry was read. A test compiles exactly that document and
refuses the other implementation.
⛔ AND IT DOES NOT ALIAS THE STORED ENTRY. The same exception is looked up once
per occurrence of the word; writing the clipped list back into the slice the map
holds would narrow it permanently, so the second paragraph of a document would
hyphenate differently from the first for no reason a reader could see. `pts[:0:0]`
and a test that looks the word up again.
## Witnesses, and the mutation that checked them
A 9-letter word whose entry offers breaks after 1, 4 and 8 letters:
- at the TeX defaults (2, 3) only the break after 4 survives;
- ⛔ with the minima opened to (1, 1) all three are offered again -- the
boundary from the other side, because a rule that refused the ends
unconditionally would be a different bug wearing this fix's name;
- minima wider than the word leave nothing, with no panic and no negative
bound.
Plus the end-to-end one: \lefthyphenmin=1 when \hyphenation{photo-graphy} is read
and 6 when the word is set, so the word must come out whole -- with its control,
the same document at 1, where the entry's break must still appear.
Run against the old behaviour (clipToMins returning pts unchanged), both change
rows go red with the right numbers and the end-to-end one prints the page text
that proves it -- "Aphoto-graphyandamanuscriptfollowhere." -- while the
"opened up" control stays GREEN, which is what makes it a control.
## Not claimed
Any corpus effect. gotex-paramcensus has not been run for \hyphenation over the
measured list, so how many papers carry an entry whose breaks the minima refuse is
unknown. The change can only REMOVE break opportunities, so a paragraph that used
one of them will set differently; whether that is nearer the reference is the A/B's
business and the corpus is not reachable from this session.
No README change: this makes the behaviour match what hyphexception.go's own
header already documented, rather than adding a capability.
Refs #765 -- this is one of its nine, not the whole census.
Co-Authored-By: Claude Opus 5 <[email protected]>
This was referenced Nov 17, 2026
tannevaled
added a commit
that referenced
this pull request
Nov 17, 2026
…tor, because -race costs 6.65x (#811) MEASURED (#799). Quiet machine, GOMAXPROCS=1 -parallel 1 -count=1, arms INTERLEAVED and the order REVERSED so a drift during the pass shows up as a disagreement between orders instead of reading as an effect: run 1 run 2 plain 17.486 s 18.175 s -race 116.361 s 121.046 s A1 -> B1 6.65x B2 -> A2 6.66x (agree to 0.2%) windows-latest was failing at 1800.5 s against its own 1800 s bound, one push run in four. That left `main` ITSELF red a quarter of the time, so "is main green?" had no stable answer, ghrelease could not tag on its first try, and three open pull requests (#807, #809, #810) were red on this lane and on nothing else -- #810 changes only a comment. At 6.65x the lane was not 10% away from comfortable, it was most of an order of magnitude away. #156 and #653 already raised this bound twice; a third raise buys a few months and the same recurrence. Expected after this change: ~270 s. ⚠ AND THAT ESTIMATE IS PESSIMISTIC: the race detector's overhead on Windows is commonly HIGHER than on darwin, and a higher multiplier means a bigger saving. ## What is given up, named A data race reachable ONLY through Windows-specific code. A race is a property of the Go program and Go's memory model is platform-independent, so everything else is still caught on ubuntu and macos, on every push and every pull request. The conformance ratchet and the 80% coverage floor still run on windows: platform BEHAVIOUR is still covered there. Only the detector is dropped. ## Why the matrix and not a shell branch The policy is declared in the matrix -- `{ os: windows-latest, race: '' }` -- rather than branched on inside the step, so that reading the matrix tells you which lane guarantees what. A reader looking for "where does -race run" finds the answer in one place. ## ⚠ What is NOT changed, deliberately The 30m bound stays, although ~270 s is expected. The first green run on this lane is what measures the new time, and changing two things at once would leave nobody able to say which did it. Once that number exists the bound can come down to something that would catch a real deadlock quickly. Verified: wfaudit reads the workflow (1 read, 0 unreadable, no findings), and `go test -count=1 ./...` is green on 11 packages at a 1-minute load of 3.16. Closes #799. 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.
A
\hyphenationentry does not escape the minimatex.web:18145-18160is one block:The exception table is consulted first, and a hit does
goto found— to thesame label the pattern scan falls through to.
foundis where the limits areimposed. So
\hyphenation{}says where a break may go, not that one must, and\lefthyphenmin/\righthyphenminrefuse an exception's breaks exactly as theyrefuse a pattern's.
⭐ The comment was right and the code was wrong
hyphexception.go's header has said so since it was written:and nothing did it.
lookupreturned the entry's breaks andhyphenation.gowrote them straight into
breakAfter. That is the harder way round to find —a reader checking the rule meets it stated correctly and moves on, and the usual
failure (a stale comment over correct code) trains you to distrust the comment,
not the code.
The pattern path was never affected:
Hyphenator.Pointsapplies the minima itself(
for t := h.lmin; t <= L-h.rmin, faithful totex.web:17677'sfor j:=l_hyf to hn-r_hyf do if odd(hyf[j])), which is why only exceptionsescaped.
Two decisions in the fix
⛔ Applied when the word is hyphenated, not when the entry is recorded. TeX
imposes the limits inside
hyphenate. A document may declare\hyphenation{}ina package and set
\lefthyphenminafterwards, or change it per languagemid-document; clipping at
addtime would freeze whichever value happened to bein force when the entry was read. A test compiles exactly that document and
refuses the other implementation.
⛔ It does not alias the stored entry. The same exception is looked up once per
occurrence of the word, so writing the clipped list back into the slice the map
holds would narrow it permanently — the second paragraph of a document would
hyphenate differently from the first, for no reason a reader could see.
pts[:0:0], and a test that looks the word up again afterwards.Witnesses, and the mutation that checked them
A 9-letter word whose entry offers breaks after 1, 4 and 8 letters:
⛔ The middle row is the boundary from the other side, and it is why the first row
means anything: a rule that refused the ends unconditionally would be a
different bug wearing this fix's name, and a test checking only that 1 and 8 were
gone would pass it.
Plus the end-to-end one:
\lefthyphenmin=1when\hyphenation{photo-graphy}isread and
6when the word is set, so the word must come out whole — with its owncontrol, the same document left at
1, where the entry's break must still appear.Run against the old behaviour (
clipToMinsreturningptsunchanged):The control stays green, which is what makes it a control.
Not claimed
⚠ Any corpus effect.
gotex-paramcensushas not been run for\hyphenationover the measured list, so how many papers carry an entry whose breaks the minima
refuse is unknown. The change can only remove break opportunities, so a
paragraph that used one will set differently; whether that is nearer the reference
is the A/B's business, and the corpus is not reachable from this session.
⚠ No README change: this makes the behaviour match what
hyphexception.go'sown header already documented, rather than adding a capability.
How it was found
A bibliography pass over
go-typeset/hyphenation, which the engine depends on andwhich has never been audited against
tex.web—priorartreports its trackerand branches clean on the subject. The library is 110 lines and has no exception
support at all:
New,AddPattern,Points,SetMins,Mins. So everyconsumer must implement
\hyphenation{}itself, above a library that already ownsthe minima — and the first implementation put the two halves of one
tex.webblock on opposite sides of an API boundary. Raised separately there.
Refs #765 — this is one of its nine, not the whole census.
🤖 Generated with Claude Code