fix(format): glue a composite separator surrounded by Unicode blanks #270
No reviewers
Labels
No labels
bug
discussion
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gram-lang/gram!270
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/format-composite-unicode-spaces"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #269.
Kitchen flags
SPACED_COMPOSITEwhatever blank surrounds the<, but the formatter's repair (rule 6) only glued a space or a tab: with a no-break space or another Unicode blank,gram formatleft in place a composite that Gram warns is broken. The fuzz harness reported it asformat-preserves-meaning | compilation differs after formatting at $.warnings[].data(rule 6 did not fire, and rule 1 lowercased the parent quoted bydata.suggestion).packages/format/src/index.ts: rule 6 takes every Unicode horizontal blank ([^\S\r\n]), never\s, since it runs before the parser finds the steps and a line break taken there would merge two steps or a comment. The comment explains why this repair, unliketrimBlanks(#200), covers those blanks.fuzz/src/normalize.ts: aSPACED_COMPOSITE'sdata.suggestionis lowercased likeparent(rule 1). Unreachable today (rule 6 now glues every<kitchen flags, so I6 skips the input): a guard should a flagged blank ever escape rule 6 again.fuzz/regressions/269-nbsp-around-composite-separator.gram.patchon@gram-lang/format.A composite cut by a line break (
@a{1} <\n@b{2}) is not affected: the parser splits the text at the line break, so kitchen never flags it.Checks: build, typecheck,
bun test(3890 pass), conformance,bun run fuzz --iterations 50000(0 signature).Once merged: merge
mainintodev/1.6.