fix(format): never glue a composite separator on a section header #292

Merged
abiwab merged 1 commit from fix/format-composite-repair-skips-headers into main 2026-11-26 21:55:35 +01:00
Owner

Fixes #291.

Rule 6 (glue a spaced composite, @a{1} < @b{2} → @a{1}<@b{2}) ran on every line, section headers included, while a ## header holds no element: its title is text the compiler keeps as written.

  • ## <@s: rule 6 took the blank after ##, rule 8 put it back; unchanged text but 2 changes reported at every pass, so gram format --check failed forever (fuzz format-idempotent, seed 1627016615, index 10547 on dev/1.6).
  • ## Zest <@lemon ~{-1 h} became ## Zest<@lemon ~{-1 h}: the compiled section title changed.

Fix: rule 6 skips header lines (## not followed by #, as rule 8 reads them, new HEADER_LINE). A ### line is a step and is still glued.

  • Tests: 2 in packages/format/tests/formatter.test.ts and fuzz/regressions/291-header-composite-repair.gram (all fail on main).
  • patch changeset for @gram-lang/format.

Checks: 3949 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, deprecations:check, audit 127 (main's baseline since #290), fuzz 50k (seed 3547255441, 0 signature). fuzz/known-failures.json stays empty.

Fixes #291. Rule 6 (glue a spaced composite, `@a{1} < @b{2}` → `@a{1}<@b{2}`) ran on every line, section headers included, while a `## ` header holds no element: its title is text the compiler keeps as written. - `## <@s`: rule 6 took the blank after `##`, rule 8 put it back; unchanged text but 2 changes reported at every pass, so `gram format --check` failed forever (fuzz `format-idempotent`, seed 1627016615, index 10547 on dev/1.6). - `## Zest <@lemon ~{-1 h}` became `## Zest<@lemon ~{-1 h}`: the compiled section title changed. Fix: rule 6 skips header lines (`##` not followed by `#`, as rule 8 reads them, new `HEADER_LINE`). A `###` line is a step and is still glued. - Tests: 2 in `packages/format/tests/formatter.test.ts` and `fuzz/regressions/291-header-composite-repair.gram` (all fail on main). - `patch` changeset for `@gram-lang/format`. Checks: 3949 pass / 1 skip / 0 fail, conformance 142/142 and 24/24 with no golden change, typecheck, biome, `deprecations:check`, audit 127 (main's baseline since #290), fuzz 50k (seed 3547255441, 0 signature). `fuzz/known-failures.json` stays empty.
fix(format): never glue a composite separator on a section header
All checks were successful
CI / Build & Test (pull_request) Successful in 4m52s
4115529141
abiwab scheduled this pull request to auto merge when all checks succeed 2026-11-26 21:49:01 +01:00
abiwab merged commit d4c6d3bba6 into main 2026-11-26 21:55:35 +01:00
abiwab deleted branch fix/format-composite-repair-skips-headers 2026-11-26 21:55:35 +01:00
Sign in to join this conversation.
No description provided.