Whole file
lark-parser/lark
The author described this change as “Fix literal range escape assertion”. It counts as a record because the checks below fail on the code as it stood at ed46efbd1 and pass on d5c9006f0, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2019-02-23
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a save note
Fix literal range escape assertion
The change
| 389 | 389 | assert start.type == end.type == 'STRING' | |
| 390 | 390 | start = start.value[1:-1] | |
| 391 | 391 | end = end.value[1:-1] | |
| 392 | - | assert len(start) == len(end) == 1, (start, end, len(start), len(end)) | |
| 392 | + | assert len(_fix_escaping(start)) == len(_fix_escaping(end)) == 1, (start, end, len(_fix_escaping(start)), len(_fix_escaping(end))) | |
| 393 | 393 | regexp = '[%s-%s]' % (start, end) | |
| 394 | 394 | return ST('pattern', [PatternRE(regexp)]) | |
| 395 | 395 |
The check that tells the two apart
fail→pass·tests/test_parser.py::TestCykStandard::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestCykStandard::test_unicode_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyDynamic::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyDynamic::test_unicode_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyDynamic_complete::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyDynamic_complete::test_unicode_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyStandard::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestEarleyStandard::test_unicode_literal_range_escape
fail→pass·tests/test_parser.py::TestLalrContextual::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestLalrContextual::test_unicode_literal_range_escape
fail→pass·tests/test_parser.py::TestLalrStandard::test_hex_literal_range_escape
fail→pass·tests/test_parser.py::TestLalrStandard::test_unicode_literal_range_escape
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 ited46efbd10b5daf154378a67f0beffbb9849bf3d
Broken version dated2019-02-15
Modulelark.load_grammar
Units changedPrepareLiterals
Fingerprint28dc66634643bf02
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