Skip to main content

Module expr

Module expr 

Source
Expand description

expr — reference evaluator for expression-ir.md (normative).

Value model: int = checked i64 (overflow → Failure, never wrap/panic), float = f64 (NaN/±Inf → Failure), string / bool / null / arr / obj.

Normative points (§6/§8 traps):

  • int arithmetic is checked i64 (overflow = INT_OVERFLOW).
  • a result that becomes NaN/±Inf is a Failure.
  • mod is truncated division (sign follows dividend; Rust % already does this).
  • string comparison is code-point order (Rust str Ord = UTF-8 byte order = code point).
  • and/or/coalesce/cond short-circuit.
  • unknown operators fail closed.

Structs§

ExprFailure

Enums§

ExprFailureCode
Expression failure codes (PROTOCOL §3.1).

Constants§

FORBIDDEN_OBJECT_KEY
Forbidden object key (expression-ir.md §2.3/§8). Any path that builds an object from IR/JSON-derived arbitrary string keys must reject an own key equal to "__proto__" fail-closed: JS drops it (prototype setter), while Python/Rust/Go keep it, so the same IR diverges across languages (prototype-pollution footgun).

Functions§

cmp_code_points
Compare two strings by code point. Rust str Ord IS UTF-8 byte order which equals Unicode code-point order, so we can delegate to the native comparison. Kept as a named function to make the normative choice explicit.
evaluate
Evaluate an IR expression node against a scope, producing a runtime Value.