[Bug]: a ':' after a cookware or an ingredient is read as an alias, swallowing the text that follows #273
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#273
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?
The component alias (
alias = ":" refNameingrammar.ohm, documented as@dry white wine:wine{10ml}) accepts a name that starts with a blank, or is only blanks.refNametakes any run of characters that are not a syntax character, a sigil or a line break, spaces included. So a:written as punctuation right after a cookware or an ingredient is read as an alias, with no message:Heat the #pan: then add oil.pan, alias"then add oil.": the rest of the line is gonea #pan: ⏎more(trailing blank)pan, alias"": the:is gonea #pan:⏎morepan, then the text:a @flour: ⏎moreThe bare form (
"#" modifier* singleWordName alias? preparation?) is the worst case: a mention without braces takes a multi-word alias, so everything up to the end of the line (or the next sigil) disappears from the step.Found by the fuzz harness (#196), as a formatter violation: rule 10 strips the trailing blank of
#pan:, the:stops being an alias and comes back as text, so the compilation changes:Present on
main(d8f1a67f) anddev/1.6(2af231a4). The formatter is right to strip the blank: the fix belongs to the grammar.Proposed fix (to decide, it changes how the grammar reads, so it is a syntax change):
:, with no blank (@dry white wine:wine{10ml}keeps working,#pan: thenbecomes a cookware followed by the text: then);tree-sitter-gram(grammar, corpus), conformance cases, the alias docs (ingredients.mdx,cookware.mdx, cheatsheet), andbun run fuzz --iterations 50000; the minimized input goes tofuzz/regressions/.