#876·monty

Parser Crash: NotImplementedError on Yield Expressions - Ungraceful Error Handling

Author: marihasdCreated Sep 16, 2026Updated Sep 16, 2026

Description The Monty parser crashes with NotImplementedError when encountering yield expressions, instead of gracefully rejecting the unsupported syntax with a SyntaxError. This causes the worker process to terminate and makes debugging difficult.

Steps to Reproduce: Minimal Reproduction Create a file test_yield.py:

def generator_function(): yield 1

print("This won't print") Run it:

uv run hackmonty.py test_yield.py 2>&1

Expected Behavior: The parser should reject unsupported syntax with a clear SyntaxError:

SyntaxError: yield expressions are not supported in this version

Actual Behavior: The parser panics with NotImplementedError, causing worker disconnection:

runtime error: NotImplementedError: The monty syntax parser does not yet support yield expressions Traceback (most recent call last): File "", line 3, in yield 1 ~~~~~~~ NotImplementedError: The monty syntax parser does not yet support yield expressions

Test Results The following yield-related syntax all trigger the same crash:

Test Case 1: Simple yield

def gen(): yield 1 Result: NotImplementedError: The monty syntax parser does not yet support yield expressions

Test Case 2: Yield with value

def gen(): x = (yield 5) Result: NotImplementedError: The monty syntax parser does not yet support yield expressions

Test Case 3: Yield in lambda (also crashes)

f = lambda: (yield 1) Result: NotImplementedError: The monty syntax parser does not yet support yield expressions

Related Issues This is part of a broader pattern where unsupported syntax causes unhandled NotImplementedError exceptions instead of graceful SyntaxError rejection. Other unsupported features that should be addressed similarly:

async/await syntax (currently passes but execution is unsupported) class inheritance (causes NotImplementedError) Method decorators (@property, @classmethod, @staticmethod - cause NotImplementedError) Root Cause Analysis The Monty parser encounters unsupported syntax and throws NotImplementedError at parse time. Instead of:

Err(NotImplementedError("...")) // Current behavior It should return:

Err(SyntaxError("...")) // Expected behavior This would allow:

Proper error reporting to users Graceful termination instead of worker crash Better debugging experience Consistency with standard Python behavior Impact Severity: Medium Scope: Parser/Semantic Analyzer Reproducibility: 100% (all yield expressions crash) User Impact: Scripts using yield fail with unhelpful error messages Suggested Fix Catch NotImplementedError in the parser for unsupported syntax Convert to proper SyntaxError with descriptive message Include line/column information for debugging Apply same pattern to other unsupported syntax (async/await, class inheritance, decorators) Environment Monty Version: 3.14.0 (Monty) Python Version: (Monty, not CPython) Test Date: August 2026 Test Method: hackmonty.py CLI via wss://hackmonty.com