Whole file
lark-parser/lark
The author described this change as “Fix #696 now providing the correct amount of placeholders”. It counts as a record because the checks below fail on the code as it stood at 44a20c850 and pass on c3fc2266e, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2021-06-26
Sharing licenceMIT · LICENSE
Change size+4 −5
What the code was meant to do, written into the code itself as a save note
Fix #696 now providing the correct amount of placeholders
The change
| 231 | 231 | return not sym.name.startswith('_') | |
| 232 | 232 | if isinstance(sym, Terminal): | |
| 233 | 233 | return keep_all_tokens or not sym.filter_out | |
| 234 | - | assert False | |
| 234 | + | if isinstance(sym, Symbol): | |
| 235 | + | return False | |
| 236 | + | assert False, sym | |
| 235 | 237 | ||
| 236 | - | if any(rule.scan_values(will_not_get_removed)): | |
| 237 | - | empty = _EMPTY | |
| 238 | - | else: | |
| 239 | - | empty = ST('expansion', []) | |
| 238 | + | empty = ST('expansion', [_EMPTY] * len(list(rule.scan_values(will_not_get_removed)))) | |
| 240 | 239 | ||
| 241 | 240 | return ST('expansions', [rule, empty]) | |
| 242 | 241 |
The check that tells the two apart
fail→pass·tests/test_parser.py::TestEarleyCustom_old::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestEarleyDynamic::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestEarleyDynamic_complete::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestEarleyStandard::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestLalrContextual::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestLalrCustom_new::test_maybe_placeholders
fail→pass·tests/test_parser.py::TestLalrStandard::test_maybe_placeholders
Check file tests/test_parser.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 it44a20c850ea7e0945a9db663a763abdcf1f86b88
Broken version dated2021-06-26
Modulelark.load_grammar
Units changedEBNF_to_BNF
Fingerprint8fac87f1c3bd7f56
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