Expand description
Escape analysis for zone safety.
Implements the zone containment rule: values can enter zones but cannot escape. This pass checks for obvious violations before code generation, providing Socratic error messages.
§The Zone Rule
Variables defined inside a zone are deallocated when the zone ends. Returning or assigning them to outer variables would create dangling references. This pass catches these common patterns with friendly errors.
§Example
Zone "temp":
Let x be 5.
Return x. ← Error: x cannot escape zone "temp"§Limitations
More complex escape patterns (e.g., through closures or indirect references) are caught by Rust’s borrow checker at compile time. This pass catches the common cases with better LOGOS-specific error messages.
Structs§
- Escape
Checker - Escape
Error - Error type for escape violations
- Escape
Finding - Tracks the “zone depth” of variables for escape analysis
One escape finding: the top-level statement it belongs to (mapping onto
Parser::stmt_spans()), and the erring statement with each one around it, innermost first (forParser::nested_stmt_spans()).