Skip to main content

Module escape

Module escape 

Source
Expand description

Escape analysis for zone safety.

Implements the “Hotel California” 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
Tracks the “zone depth” of variables for escape analysis
EscapeError
Error type for escape violations

Enums§

EscapeErrorKind