[Bug]: gram format leaves a spaced composite with a no-break space around '<' unglued #269
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#269
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Kitchen flags
SPACED_COMPOSITEwhatever blank surrounds the<(packages/kitchen/src/spaced-composite.tstrims the text between the two ingredients), but the formatter's repair (rule 6,packages/format/src/index.ts) only glued a space or a tab. With a no-break space (U+00A0) or another Unicode blank,gram formatleft in place a composite that Gram warns is broken:The fuzz harness (#196) reports it as a change of meaning once an id has a capital letter: rule 6 did not fire, so I6 compared the two compilations, and rule 1 lowercased the parent quoted by
data.suggestion(<@Lemon→<@lemon):Present on
mainsinceSPACED_COMPOSITEshipped in 1.5.2. Not caught by the fixed-seed fuzz test; found bybun run fuzz --iterations 50000(seed 540879751).Fix (patch on
@gram-lang/format):[^\S\r\n]), never\s: it runs before the parser finds the steps, and a line break taken there would merge two steps or a comment;fuzz/src/normalize.tslowercases aSPACED_COMPOSITE'sdata.suggestionlikeparent(rule 1), as a guard should a blank kitchen flags ever escape rule 6 again;fuzz/regressions/.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.