Whole file
lark-parser/lark
The author described this change as “Raise GrammarError for non-terminal names in %declare”. It counts as a record because the check below fails on the code as it stood at 5718472e5 and passes on 59f774f14, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2026-06-04
Sharing licenceMIT · LICENSE
Change size+2 −0
What the code was meant to do, written into the code itself as a save note
Raise GrammarError for non-terminal names in %declare
The change
| 1274 | 1274 | for symbol in stmt.children: | |
| 1275 | 1275 | assert isinstance(symbol, Symbol), symbol | |
| 1276 | 1276 | is_term = isinstance(symbol, Terminal) | |
| 1277 | + | if not is_term: | |
| 1278 | + | raise GrammarError("Expecting terminal name to follow %%declare, but got rule name %r" % symbol.name) | |
| 1277 | 1279 | if mangle is None: | |
| 1278 | 1280 | name = symbol.name | |
| 1279 | 1281 | else: |
The check that tells the two apart
fail→pass·tests/test_grammar.py::TestGrammar::test_declare_rule_name
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 it5718472e57a08aac3728c2f26f902de56c48d64c
Broken version dated2026-06-03
Modulelark.load_grammar
Units changedGrammarBuilder
Fingerprint6445baafeca58722
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-02Fix empty SPPF node from xearley ignore carry-over (fixes #1598)
- 2026-05-24fix: raise GrammarError for template usage inside terminals
- 2024-10-25Adjust behaviour in #1481 to raise a NotImplementedError
- 2024-10-25Fix Symbol.__eq__ (fixes #1476)