Files
hakorune/docs/papers/block_postfix_catch.md

22 lines
960 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# BlockPostfix Catch Language Design (Draft)
Goal
- Make exception boundaries explicit by attaching `catch`/`cleanup` to standalone blocks.
Design
- Syntax: `{ body } catch (e) { handler } [cleanup { … }]` and `{ body } cleanup { … }`.
- Policy: single catch (branch inside the catch); scope limited to the same block; no implicit propagation.
- Static check (MVP): direct `throw` in a standalone block requires an immediate postfix `catch`.
Implementation Notes
- Parser (gated): normalize postfix to `ASTNode::TryCatch`.
- Bridge(Resultmode): ThrowCtx routes nested `throw` to the single catch; merge with PHIoff.
- Friendly errors: disallow toplevel leading `catch`/`cleanup`, and attaching to structural if/loop blocks.
References
- Parser: `src/parser/statements.rs`
- Smokes: `src/tests/parser_block_postfix_{catch,errors}.rs`
Open Questions
- Multiple catch with type hierarchy; effects typing for static checks; formatter support.