Skip to content

feat: try with exception edges, await and yield - #36

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/try
Sep 4, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/try

Conversation

@SizzleUnrlsd

@SizzleUnrlsd SizzleUnrlsd commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

try with exception edges, plus await and yield: the last open bullets of the PyHIR node set (#25) and of the CFG item (#11).

  • Acceptance tests first (test: define try, exception edges, await and yield behavior), implementation follows.
  • PyHIR: Try with ExceptHandler (type, bound name, body), else and finally; Await and Yield expressions. except* groups and yield from stay explicit diagnostics.
  • CFG (§5 exception edges): every block laid out inside a try body carries exception edges to the handler blocks, so a raise or a call in the body can reach a handler; cfg.successors and predecessors include them, and so do dominance, reachability and back edges. Handlers, else and finally join after the statement; finally is modelled on the normal path only, exceptional exits are an approximation. Integrity checks cover exception targets.
  • PyIR: blocks carry their exception targets (try_1 [except: handler_1]: in --emit-ir), handlers start with catch, and await / yield are instructions. SSA places phis at handlers and joins through the exception edges.
  • Data-flow problems (constants, dependencies, taint) send a block's exit state along its exception edges, so taint reaches handlers and finally bodies.

--check no longer reports functions using try as unsupported.

Closes #25 (its last open bullets) and the exception-edges bullet of #11.

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 3, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit eebd838 into main Sep 4, 2026
6 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/try branch September 4, 2026 00:00
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.

Complete the PyHIR node set

1 participant