Module dimension_check
Expand description
Dimension-aware static analysis — rejects dimension-incoherent quantity arithmetic at COMPILE
time, before any code is generated. 2 meters + 1 gram is a type error, not a runtime panic:
a length and a mass have no common dimension, so adding them cannot mean anything.
This is a dedicated pass in the crate::analysis::escape::EscapeChecker /
crate::analysis::ownership mold, wired as a gate in compile.rs. It runs on the SAME AST the
interpreter and the AOT compiler share, so a dimension error is reported identically on every tier
before execution.
Soundness is conservative. Every quantity value already carries its dimension at runtime;
this pass only adds a static rejection where it can PROVE incompatibility — i.e. when both
operands’ dimensions are statically known and differ. A quantity of unknown dimension (a
Quantity function parameter, a collection element, a value from an opaque call) is treated as
dimension-polymorphic and deferred to the existing runtime check. So this pass never rejects a
correct program; it only promotes provable runtime failures to compile-time errors.
Structs§
- Dimension
Checker - Dimension
Error - A dimension coherence error, with the same shape the other analysis passes use so
compile.rscan convert it to aParseErroruniformly.