Module analysis
Expand description
Re-export of analysis utilities from the compile crate.
Useful for tooling that needs to analyze LOGOS source without performing a full build. Compile-time analysis passes for the LOGOS compilation pipeline.
This module provides static analysis that runs after parsing but before code generation. These passes detect errors that would otherwise manifest as confusing Rust borrow checker errors.
§Analysis Passes
| Pass | Module | Description |
|---|---|---|
| Escape | escape | Detects zone-local values escaping their scope |
| Ownership | ownership | Linear type enforcement (use-after-move) |
| Discovery | discover_with_imports | Multi-file type discovery |
§Pass Ordering
Parser Output (AST)
│
▼
┌──────────────┐
│ Escape Check │ ← Catches zone violations (fast, simple)
└──────────────┘
│
▼
┌─────────────────┐
│ Ownership Check │ ← Catches use-after-move (control-flow aware)
└─────────────────┘
│
▼
Code Generation§Re-exports
This module re-exports types from logicaffeine_language::analysis for
convenience, including:
TypeRegistry,TypeDef,FieldDef- Type definitionsPolicyRegistry,PredicateDef,CapabilityDef- Security policiesDiscoveryPass- Token-level type discovery
Modules§
- callgraph
- check
- Bidirectional type checker for the LOGOS compilation pipeline.
- dependencies
- dimension_
check - Dimension-aware static analysis — rejects dimension-incoherent quantity arithmetic at COMPILE
time, before any code is generated.
2 meters + 1 gramis a type error, not a runtime panic: a length and a mass have no common dimension, so adding them cannot mean anything. - escape
- Escape analysis for zone safety.
- liveness
- ownership
- Native ownership analysis for use-after-move detection.
- policy
- readonly
- registry
- types
- Type inference pass for the LOGOS compilation pipeline.
- unify
- Unification engine for the bidirectional type checker.
Structs§
- Capability
Def - A capability definition:
A User can publish the Document if... - Dependency
- A dependency declaration found in the document’s abstract.
- Dimension
Checker - Dimension
Error - A dimension coherence error, with the same shape the other analysis passes use so
compile.rscan convert it to aParseErroruniformly. - Discovery
Pass - Discovery pass that scans tokens before main parsing to build a TypeRegistry.
- Discovery
Result - Result of running the discovery pass
- Escape
Checker - Tracks the “zone depth” of variables for escape analysis
- Escape
Error - Error type for escape violations
- Field
Def - Field definition within a struct
- FnSig
- Function signature for tracked functions.
- Indexed
Type Error - Check a LOGOS program and return a typed
TypeEnvfor codegen. - Ownership
Checker - Ownership checker - tracks variable states through control flow
- Ownership
Error - Error type for ownership violations
- Ownership
Finding - One ownership finding with its statement coordinates: the top-level
statement that ERRED, and (when known) the one that CAUSED it by moving
the variable. Both map 1:1 onto
Parser::stmt_spans(). - Policy
Registry - Registry for security policies defined in
## Policyblocks. - Predicate
Def - A predicate definition:
A User is admin if the user's role equals "admin". - Rust
Names - Centralized name resolution for Rust identifier output.
- TypeEnv
- Type environment built by a forward pass over the AST.
- Type
Registry - Variant
Def - Phase 33: Variant definition for sum types
Enums§
- Escape
Error Kind - Field
Type - Type reference for struct fields (avoids circular deps with ast::TypeExpr)
- Logos
Type - Structured type representation for LOGOS values.
- Ownership
Error Kind - Policy
Condition - Condition in a policy definition. Represents the predicate logic for security rules.
- TypeDef
- VarState
- Ownership state for a variable
Functions§
- check_
program - genuine type contradictions (e.g.,
Let x: Int be "hello"). Ambiguous types fall back toLogosType::Unknownsilently. - check_
program_ collect - Collect EVERY failing top-level statement instead of bailing at the first.
- discover_
with_ imports - Recursive discovery with module imports.
- scan_
dependencies - Scans the first paragraph (Abstract) of a LOGOS file for
[Alias](URI)links.