Whole file
lark-parser/lark
The author described this change as “fix: raise GrammarError for template usage inside terminals”. It counts as a record because the check below fails on the code as it stood at eb015d1b5 and passes on 92047e919, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2026-05-24
Sharing licenceMIT · LICENSE
Change size+2 −0
What the code was meant to do, written into the code itself as a save note
fix: raise GrammarError for template usage inside terminals
The change
| 704 | 704 | for name, (term_tree, priority) in term_defs: | |
| 705 | 705 | if term_tree is None: # Terminal added through %declare | |
| 706 | 706 | continue | |
| 707 | + | if next(term_tree.find_data('template_usage'), None) is not None: | |
| 708 | + | raise GrammarError("Templates cannot be used inside terminals (%s)" % name) | |
| 707 | 709 | expansions = list(term_tree.find_data('expansion')) | |
| 708 | 710 | if len(expansions) == 1 and not expansions[0].children: | |
| 709 | 711 | raise GrammarError("Terminals cannot be empty (%s)" % name) |
The check that tells the two apart
fail→pass·tests/test_grammar.py::TestGrammar::test_template_in_terminal
Check file tests/test_grammar.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before iteb015d1b5c236b22bf3215fd4a76c891262e1bf8
Broken version dated2026-05-09
Modulelark.load_grammar
Units changedGrammar
Fingerprint9b1a52df1388c430
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in lark-parser/lark
- 2026-07-08Fix lexer_callbacks silently dropped for keyword terminals
- 2026-06-24Transformer_NonRecursive
- 2026-06-04Raise GrammarError for non-terminal names in %declare
- 2026-06-02Fix empty SPPF node from xearley ignore carry-over (fixes #1598)
- 2024-10-25Adjust behaviour in #1481 to raise a NotImplementedError
- 2024-10-25Fix Symbol.__eq__ (fixes #1476)