Whole file
lark-parser/lark
The author described this change as “Fix lexer_callbacks silently dropped for keyword terminals”. It counts as a record because the check below fails on the code as it stood at c169b26a5 and passes on 46bbc82b3, with nothing else changed between the two runs.
Projectlark-parser/lark
Fix saved2026-07-08
Sharing licenceMIT · LICENSE
Change size+7 −2
What the code was meant to do, written into the code itself as a save note
Fix lexer_callbacks silently dropped for keyword terminals
The change
| 595 | 595 | ||
| 596 | 596 | for type_, f in self.user_callbacks.items(): | |
| 597 | 597 | if type_ in self.callback: | |
| 598 | - | # Already a callback there, probably UnlessCallback | |
| 599 | - | self.callback[type_] = CallChain(self.callback[type_], f, lambda t: t.type == type_) | |
| 598 | + | # Already a callback there, probably UnlessCallback. | |
| 599 | + | # Bind ``type_`` per iteration; otherwise every CallChain's | |
| 600 | + | # condition closes over the loop variable and checks the last | |
| 601 | + | # terminal's name, silently skipping the other callbacks. | |
| 602 | + | self.callback[type_] = CallChain( | |
| 603 | + | self.callback[type_], f, lambda t, type_=type_: t.type == type_ | |
| 604 | + | ) | |
| 600 | 605 | else: | |
| 601 | 606 | self.callback[type_] = f | |
| 602 | 607 |
The check that tells the two apart
fail→pass·tests/test_grammar.py::TestGrammar::test_lexer_callbacks_with_keyword_terminals
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 itc169b26a5bec9d47e590bf4be83691bcbdfe7b6b
Broken version dated2026-06-04
Modulelark.lexer
Units changedBasicLexer
Fingerprint7399096dd2eb277d
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-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
- 2024-10-25Fix Symbol.__eq__ (fixes #1476)