Skip to main content

Module escape

Module escape 

Source
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§

EscapeChecker
EscapeError
Error type for escape violations
EscapeFinding
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 (for Parser::nested_stmt_spans()).

Enums§

EscapeErrorKind