Skip to content

Fix return simplifier crash on parameter returns#5

Merged
alvinwan merged 3 commits intomainfrom
dev/alvin/fix-return-simplifier-crash
Apr 4, 2026
Merged

Fix return simplifier crash on parameter returns#5
alvinwan merged 3 commits intomainfrom
dev/alvin/fix-return-simplifier-crash

Conversation

@alvinwan
Copy link
Copy Markdown
Owner

@alvinwan alvinwan commented Apr 4, 2026

Summary

  • restrict return simplification to adjacent assign; return name pairs in the same statement list
  • remove simplified assignments by node identity instead of by variable name
  • add a regression test covering the reported return path parameter crash

Why

The simplifier assumed any return <name> referred to a preceding assignment stored in a global name map. Returning a parameter or other local name with no matching assignment raised a KeyError, and deleting assignments by name was broader than the actual simplification target.

Validation

  • .venv/bin/python -m pytest
  • python3 -m py_compile pymini/pymini.py tests/test_api.py

@alvinwan alvinwan merged commit 1b56bac into main Apr 4, 2026
10 checks passed
@alvinwan alvinwan deleted the dev/alvin/fix-return-simplifier-crash branch April 4, 2026 09:40
@alvinwan alvinwan mentioned this pull request Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant