pub enum TypedExprKind {
Show 43 variants
Number(f64),
BigInt(String),
String(String),
Boolean(bool),
Null,
Undefined,
This,
Regex {
source: String,
flags: String,
},
LocalRef {
ident: Ident,
boxed: bool,
},
LocalNarrowRef {
binding: Ident,
path: ReferencePath,
},
GlobalRef {
mangled: MangledName,
name: Ident,
},
FunctionRef {
mangled: MangledName,
name: Ident,
},
EffectThen {
effect: ExprId,
result: ExprId,
},
Sequence {
stmts: Vec<StmtId>,
result: ExprId,
},
Binary {
op: BinOp,
lhs: ExprId,
rhs: ExprId,
},
Unary {
op: UnOp,
operand: ExprId,
},
Call {
mangled: MangledName,
args: Vec<ExprId>,
type_predicate: Option<Box<TypePredicate>>,
},
CallClosure {
callee: ExprId,
args: Vec<ExprId>,
},
McpCall {
server: String,
tool: String,
args: Vec<ExprId>,
},
GenericCall {
mangled: MangledName,
type_args: Vec<Type>,
args: Vec<GenericArgument>,
return_cast: Option<Type>,
type_predicate: Option<Box<TypePredicate>>,
},
IntrinsicCall {
kind: Intrinsic,
args: Vec<ExprId>,
},
MethodCall {
receiver: ExprId,
iface: MangledName,
name: Ident,
args: Vec<ExprId>,
type_predicate: Option<Box<TypePredicate>>,
},
SuperCtorCall {
parent: MangledName,
args: Vec<ExprId>,
},
SuperMethodCall {
owner: MangledName,
name: Ident,
args: Vec<ExprId>,
},
GenericMethodCall {
receiver: ExprId,
iface: MangledName,
name: Ident,
args: Vec<GenericArgument>,
return_cast: Option<Type>,
type_predicate: Option<Box<TypePredicate>>,
},
ObjectLiteral {
members: Vec<TypedObjectMember>,
fields: Vec<TypedObjectFieldOrigin>,
},
ArrayLiteral {
elements: Vec<TypedArrayElement>,
element_ty: Type,
},
TupleLiteral {
elements: Vec<ExprId>,
element_types: Vec<Type>,
},
FieldAccess {
receiver: ExprId,
name: Ident,
},
InterfacePropertyAccess {
receiver: ExprId,
iface: MangledName,
name: Ident,
},
NumberEnumMember {
enum_mangled: MangledName,
variant: Ident,
value: f64,
},
StringEnumMember {
enum_mangled: MangledName,
variant: Ident,
value: String,
},
IndexAccess {
receiver: ExprId,
index: ExprId,
},
Closure {
runtime_generics: Vec<String>,
params: Vec<TypedParam>,
return_type: Type,
body: ClosureBody,
captured: Vec<CapturedVar>,
},
TypeofTag {
value: ExprId,
tag: TypeofTagKind,
},
Narrowed {
path: ReferencePath,
source: ExprId,
binding: Ident,
cast_info: CastInfo,
inner: ExprId,
},
Ternary {
cond: ExprId,
then_: ExprId,
else_: ExprId,
},
NullishCoalesce {
lhs: ExprId,
rhs: ExprId,
},
OptionalChain {
base: ExprId,
parts: Vec<TypedChainPart>,
},
PostfixUnary {
op: PostfixOp,
target: PostfixTarget,
},
NonNullAssert {
value: ExprId,
},
Cast {
value: ExprId,
target_ty: Type,
check: Option<Box<Type>>,
},
InstanceOf {
value: ExprId,
class: Type,
},
}Variants§
Number(f64)
BigInt(String)
bigint literal — no n suffix, no sign; negatives are Unary { Neg, … }.
String(String)
Boolean(bool)
Null
Undefined
This
this inside a class method or constructor body. A leaf; TypedExpr.ty
carries the enclosing class’s Type::ClassRef. Codegen lowers it to
local.get <this-slot> (the receiver param for methods, the allocated
instance local for constructors).
Regex
LocalRef
LocalNarrowRef
Narrowed shadow of a LocalRef/GlobalRef. binding holds the synthetic
#narrow_<N> ident so tooling can recover path without string-matching the
# prefix. No boxed field — shadows are region-scoped and never mutated.
GlobalRef
FunctionRef
Distinct from GlobalRef — codegen lowers to a closure adapter, not global.get.
EffectThen
Evaluate effect, discard its value, then yield result.
The void operator lowers to this with an undefined result. It also
lets a fold that decides an expression’s value statically keep the
computation that produced the operand: typeof f() === "number" has a constant answer when f’s return type decides the tag,
but JS evaluates the operand either way.
Sequence
Run stmts in order, then yield result. An assignment used as a value
lowers to this: its assignment statement, then a read of what it assigned.
stmts declares no binding that outlives the expression.
Binary
Unary
Call
Static dispatch. Closure-through-value invocation goes through CallClosure instead.
Fields
mangled: MangledNametype_predicate: Option<Box<TypePredicate>>Type guard predicate from callee’s signature; codegen ignores it.
CallClosure
call_ref dispatch; distinct from Call (direct call instruction).
McpCall
@mcp/<server>.<tool>(args) — dispatched through the single
submilli:mcp.call host fn rather than a per-tool import. Carries the
server and tool names directly, so codegen needs no mangled-name parsing.
The result type (on the containing TypedExpr) drives how the returned JSON
text is materialized (a string, or a typed value via the JSON.parse
validator).
GenericCall
Callee signature has bare Type::TypeVar slots. Per-position is_generic flags
and return_cast drive box/cast at the call boundary. Always statically dispatched
(no generic closures).
Fields
mangled: MangledNameargs: Vec<GenericArgument>return_cast: Option<Type>Some(T) when the unsubstituted return is a bare TypeVar; codegen emits a
cast to materialize the call-site type. None when return is already concrete.
type_predicate: Option<Box<TypePredicate>>IntrinsicCall
Intrinsic recognised by name in the inferer; bypasses the normal Call path.
MethodCall
Interface method dispatch. Codegen composes <iface>#<name> to find the
direct-dispatch thunk, falling back to vtable dispatch.
SuperCtorCall
super(...) in a subclass constructor: a direct call of the parent’s
constructor init fn on the current this (self-first ABI). Codegen
pushes this then the args. Type is Void.
SuperMethodCall
super.method(...): a direct call of the parent body that declares the
method (owner), skipping vtable dispatch so it doesn’t re-resolve to the
override. Codegen pushes this then the args.
GenericMethodCall
MethodSig has a bare TypeVar in args or return. HOF methods (map, filter, …)
with TypeVar only inside composites stay as plain MethodCall. Variadic trailing
args are pre-packed by the typechecker, so args.len() always matches params.len() 1:1.
Fields
iface: MangledNameargs: Vec<GenericArgument>type_predicate: Option<Box<TypePredicate>>Guard predicate after type-arg substitution; codegen ignores it.
ObjectLiteral
fields records the static shape in canonical order. members retains
source evaluation order. In a spread literal, ordinary properties become
singleton object sources so each source can be copied immediately.
Fields
members: Vec<TypedObjectMember>Every expression the literal evaluates, in source order, as JavaScript evaluates them. A value a later member overwrites is still here: it is evaluated for its effects and then discarded. Each field’s source refers to one of these.
fields: Vec<TypedObjectFieldOrigin>ArrayLiteral
element_ty lets codegen pick the wrapper struct’s element type without re-running inference.
TupleLiteral
Same source syntax as ArrayLiteral; emitted when the expected type is Type::Tuple.
element_types drives per-slot boxing in codegen.
FieldAccess
InterfacePropertyAccess
Distinct from FieldAccess — codegen composes <iface>#<name> rather than a struct field offset.
NumberEnumMember
Enum name is a compile-time namespace with no runtime representation; value is
stored inline so codegen emits i32.const N.
StringEnumMember
Codegen emits a string-pool reference rather than i32.const.
IndexAccess
Closure
captured is empty until the capture pass runs; codegen reads entries in order as env struct slots.
TypeofTag
typeof x === "<tag>" check. Distinct from Is so primitive type-test codegen
stays free of vtable/shape-disjunction logic (Object and Function need both).
Narrowed
Wraps the dependent side of &&/||/ternary. See docs/narrowing.md primitive #6.
Ternary
Narrowing on cond flows into then_ (true env) and else_ (false env).
NullishCoalesce
a ?? b. Result type is union(strip_null(lhs.ty), rhs.ty).
OptionalChain
Each part carries result_ty so codegen steps through without re-running inference.
Containing TypedExpr.ty is union(tail_result_ty, Null).
PostfixUnary
Statement-position uses are desugared into AssignLocal/AssignGlobal/etc. before
codegen; only expression-position uses reach here.
NonNullAssert
value! — runtime-checked non-null assertion. Throws Error on null.
Cast
value as target_ty. check carries the structural shape to validate at runtime
(the target with interfaces reduced to object shapes) when the source isn’t a static
subtype of the target; None for a statically-proven upcast (repr-only narrow, no
runtime test).
InstanceOf
x instanceof Foo — lowers to ref.test (ref $Foo). class is the resolved
Type::ClassRef; the result type is boolean.