[Bug]: a ':' after a cookware or an ingredient is read as an alias, swallowing the text that follows #273

Closed
opened 2026-11-26 13:54:22 +01:00 by abiwab · 0 comments
Owner

The component alias (alias = ":" refName in grammar.ohm, documented as @dry white wine:wine{10ml}) accepts a name that starts with a blank, or is only blanks. refName takes 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:

Source Read as
Heat the #pan: then add oil. cookware pan, alias "then add oil.": the rest of the line is gone
a #pan: ⏎more (trailing blank) cookware pan, alias "": the : is gone
a #pan:⏎more cookware pan, then the text :
a @flour: ⏎more the same for an ingredient

The 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:

Signature: format-preserves-meaning | compilation differs after formatting at $.sections[].steps[]
Minimized: ---\nti#tle: \r\n---\n\nStep.\n    (the invalid key makes the block a step, `#tle` a cookware)
Replay:    bun run fuzz --iterations 50000 --seed 2725035355 (index 964 on the dev/1.6 corpus of PR #272)

Present on main (d8f1a67f) and dev/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):

  • an alias name starts right after the :, with no blank (@dry white wine:wine{10ml} keeps working, #pan: then becomes a cookware followed by the text : then);
  • possibly, a bare mention (no braces) only takes a single-word alias, like its single-word name;
  • reaches tree-sitter-gram (grammar, corpus), conformance cases, the alias docs (ingredients.mdx, cookware.mdx, cheatsheet), and bun run fuzz --iterations 50000; the minimized input goes to fuzz/regressions/.
The component alias (`alias = ":" refName` in `grammar.ohm`, documented as `@dry white wine:wine{10ml}`) accepts a name that starts with a blank, or is only blanks. `refName` takes 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: | Source | Read as | |---|---| | `Heat the #pan: then add oil.` | cookware `pan`, alias `"then add oil."`: **the rest of the line is gone** | | `a #pan: ⏎more` (trailing blank) | cookware `pan`, alias `""`: the `:` is gone | | `a #pan:⏎more` | cookware `pan`, then the text `:` | | `a @flour: ⏎more` | the same for an ingredient | The 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: ``` Signature: format-preserves-meaning | compilation differs after formatting at $.sections[].steps[] Minimized: ---\nti#tle: \r\n---\n\nStep.\n (the invalid key makes the block a step, `#tle` a cookware) Replay: bun run fuzz --iterations 50000 --seed 2725035355 (index 964 on the dev/1.6 corpus of PR #272) ``` Present on `main` (`d8f1a67f`) and `dev/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): - an alias name starts right after the `:`, with no blank (`@dry white wine:wine{10ml}` keeps working, `#pan: then` becomes a cookware followed by the text `: then`); - possibly, a bare mention (no braces) only takes a single-word alias, like its single-word name; - reaches `tree-sitter-gram` (grammar, corpus), conformance cases, the alias docs (`ingredients.mdx`, `cookware.mdx`, cheatsheet), and `bun run fuzz --iterations 50000`; the minimized input goes to `fuzz/regressions/`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#273
No description provided.