Whole file
lark-parser/lark
The author described this change as “Raise a GrammarError on empty string literal.”. It counts as a record because the check below fails on the code as it stood at f7cde8766 and passes on c44bb3e0c, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2021-06-22
Sharing licenceMIT · LICENSE
Change size+3 −0
What the code was meant to do, written into the code itself as a save note
Raise a GrammarError on empty string literal.
The change
| 448 | 448 | ||
| 449 | 449 | s = eval_escaping(x) | |
| 450 | 450 | ||
| 451 | + | if s == "": | |
| 452 | + | raise GrammarError("Can't have empty terminals (offending literal: %s)" % literal.value) | |
| 453 | + | ||
| 451 | 454 | if literal.type == 'STRING': | |
| 452 | 455 | s = s.replace('\\\\', '\\') | |
| 453 | 456 | return PatternStr(s, flags, raw=literal.value) |
The check that tells the two apart
fail→pass·tests/test_grammar.py::TestGrammar::test_empty_literal
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 itf7cde8766de619fc4490d914c8b9cfe1c97e2479
Broken version dated2021-05-23
Modulelark.load_grammar
Units changed_literal_to_pattern
Fingerprintec28b316de6e3d54
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)
- 2026-05-24fix: raise GrammarError for template usage inside terminals
- 2024-10-25Adjust behaviour in #1481 to raise a NotImplementedError