harbor run -t openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-03388
harbor download openthoughts/tasktrove-swe-rebench-patched-oracle-swe_rebench-03388
cd /testbed git clone https://github.com/lark-parser/lark.git . && git checkout 1f56497de8d90c6136dcda0ce71f4de3b298a07e apt-get update apt-get install -y gcc pip install -r /setup_files/requirements.txt pip install -e .[dev] pip install Js2Py regex pytest pytest-cov
Transformer_NonRecursive fails on Discard Describe the bug
As documented, Transformer catches any Discard exceptions and removes the node from the tree.
Transformer
Discard
I expected Transformer_NonRecursive to behave the same way - instead it lets the exception propagate eventually crashing the program.
Transformer_NonRecursive
To Reproduce
tree = Tree('start', [ Tree('add', [Token('N', '1'), Token('N', '2'), Token('token_ignore', '4')]), Tree('add', [Token('N', '3'), Token('N', '4')]), Tree('ignore_tree', [Token('DO', 'NOT PANIC')]), ]) for base in (Transformer, Transformer_InPlace, Transformer_NonRecursive, Transformer_InPlaceRecursive): class T(base): def add(self, children): return sum(children) def N(self, token): return int(token) def ignore_tree(self, children): raise Discard def token_ignore(self, token): raise Discard