pub enum ExprKind {
Show 31 variants
Number(f64),
BigInt(String),
String(String),
Boolean(bool),
Null,
Identifier(Ident),
Binary {
op: BinOp,
lhs: ExprId,
rhs: ExprId,
},
Unary {
op: UnOp,
operand: ExprId,
},
Call {
callee: ExprId,
type_args: Option<Vec<TypeAnnotation>>,
args: Vec<ExprId>,
},
Paren(ExprId),
ObjectLiteral {
members: Vec<ObjectLiteralMember>,
},
ArrayLiteral {
elements: Vec<ArrayLiteralElement>,
},
FieldAccess {
receiver: ExprId,
name: Ident,
},
IndexAccess {
receiver: ExprId,
index: ExprId,
},
FunctionExpression {
name: Option<Ident>,
this_type: Option<TypeAnnotation>,
function: ExprId,
},
Arrow {
params: Vec<ParamDecl>,
return_type: Option<TypeAnnotation>,
type_predicate: Option<TypePredicateAnnotation>,
body: ArrowBody,
},
Void {
operand: ExprId,
},
Typeof {
operand: ExprId,
},
Delete {
operand: ExprId,
},
New {
callee: ExprId,
type_args: Option<Vec<TypeAnnotation>>,
args: Vec<ExprId>,
},
This,
ThisOutsideReceiver,
Super,
TemplateLiteral {
parts: Vec<String>,
exprs: Vec<ExprId>,
substitution_spans: Vec<Span>,
},
Ternary {
cond: ExprId,
then_: ExprId,
else_: ExprId,
},
OptionalChain {
base: ExprId,
parts: Vec<ChainPart>,
},
PostfixUnary {
op: PostfixOp,
operand: ExprId,
},
Assign {
target: ExprId,
op: Option<BinOp>,
op_span: Span,
value: ExprId,
},
As {
expr: ExprId,
ty: TypeAnnotation,
},
InstanceOf {
value: ExprId,
ty: TypeAnnotation,
},
Regex {
source: String,
flags: String,
},
}Variants§
Number(f64)
BigInt(String)
Sign-free decimal digits; sign is the enclosing Unary { op: Neg }. Codegen packs into limbs.
String(String)
Boolean(bool)
Null
Identifier(Ident)
Binary
Unary
Call
Paren(ExprId)
ObjectLiteral
Fields
members: Vec<ObjectLiteralMember>ArrayLiteral
Fields
elements: Vec<ArrayLiteralElement>FieldAccess
IndexAccess
FunctionExpression
Arrow
Void
Evaluate the operand for effects and produce undefined.
Typeof
typeof x — only valid against a string-literal tag. Folded into TypedExprKind::TypeofTag; never appears in the typed AST.
Delete
delete o.x — parsed so the typechecker can reject it by name rather than
as a stray identifier; never appears in the typed AST.
New
new Foo(args). Lowered to TypedExprKind::MethodCall by the typechecker; codegen never sees this variant.
This
this — a class receiver, a function receiver, or an arrow capture.
Span lives on the enclosing Expr.
ThisOutsideReceiver
this parsed across a receiver boundary. Keep this distinction when
method shorthand is lowered to an arrow; inference owns the diagnostic.
Super
super — composes with Call/FieldAccess for super(...) / super.method(...).
TemplateLiteral
parts.len() == exprs.len() + 1. No-substitution `plain` is collapsed to String by the parser.
Fields
Ternary
OptionalChain
PostfixUnary
Assign
An assignment used as a value: b = (a = 3), while ((m = next()) !== null).
It yields the assigned value. One in statement position is parsed as an
assignment statement instead. target is an identifier, field access, or
index access; op is set for a compound assignment (+=).
As
x as T — runtime-checked, unlike TypeScript’s unchecked as. Codegen emits ref.test; throws Error on mismatch.
InstanceOf
x instanceof Foo — runtime nominal class test: a ref.eq walk over the
vtable-singleton parent chain (docs/classes.md §9). The right-hand side
names a class type, not a value.
Regex
Regex literal. Pattern and flags validated at compile time; Diagnostic on invalid pattern or flag.