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
strOrd = UTF-8 byte order = code point). - and/or/coalesce/cond short-circuit.
- unknown operators fail closed.
Structs§
Enums§
- Expr
Failure Code - 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
strOrd 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.