One function

Transformer_NonRecursive in lark-parser/lark

The author described this change as Fix Transformer_NonRecursive crashing with ValueError when root is discarded. It counts as a record because the check below fails on the code as it stood at c169b26a5 and passes on 42057206b, with nothing else changed between the two runs.

Fix saved2026-06-24
Sharing licenceMIT · LICENSE
Change size+2 0

What the code was meant to do, written into the code itself as a docstring

Same as Transformer but non-recursive. Like Transformer, it doesn't change the original tree. Useful for huge trees.

The change

3838 else:
3939 stack.append(x)
4040
41+ if not stack:
42+ return None # type: ignore[return-value]
4143 result, = stack # We should have only one tree remaining
4244 # There are no guarantees on the type of the value produced by calling a user func for a
4345 # child will produce. This means type system can't statically know that the final result is

The check that tells the two apart

failpass·tests/test_trees.py::TestTrees::test_transformer_discard_root

Check file tests/test_trees.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.visitors
Units changedTransformer_NonRecursive
Fingerprint913badfe235034f6
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