Scan `raise`, `assert` and `except` expressions for closure captures

Merged
RE
2mo ago
+75-4

A local captured by a lambda inside a raise, an assert or an except type expression panicked the worker ("LoadCell/StoreCell: expected cell reference in local slot 0").

def main():
    b = 1
    if 0:
        raise ValueError((lambda: b)())
    return b

prepare's cell-variable pre-scan skipped those nodes via a catch-all _ => {} arm, so earlier stores compiled as plain stores that overwrote the frame's cell; it now visits them, and the catch-all is replaced by an explicit list of expression-free nodes.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes a worker panic when a lambda inside a raise, assert, or except expression captures a local, e.g. raise ValueError((lambda: b)()).

The cell-variable pre-scan in prepare skipped these nodes with a catch-all arm, so earlier stores compiled as plain stores that overwrote the frame's cell. The pre-scan now visits these expressions, and the catch-all is replaced by an explicit list of expression-free nodes. Adds test cases covering dead branches, run-time raises, assert messages and conditions, and except type.