pub enum StmtKind {
Show 32 variants
Let {
name: Ident,
ty: Option<TypeAnnotation>,
value: ExprId,
doc: Option<DocComment>,
},
Const {
name: Ident,
ty: Option<TypeAnnotation>,
value: ExprId,
doc: Option<DocComment>,
},
LetPattern {
binding: Binding,
ty: Option<TypeAnnotation>,
value: ExprId,
doc: Option<DocComment>,
},
ConstPattern {
binding: Binding,
ty: Option<TypeAnnotation>,
value: ExprId,
doc: Option<DocComment>,
},
ObjectRest {
is_const: bool,
name: Ident,
source: ExprId,
exclude: Vec<Ident>,
ty: Option<TypeAnnotation>,
doc: Option<DocComment>,
},
Function {
name: Ident,
generics: Vec<Ident>,
params: Vec<ParamDecl>,
return_type: Option<TypeAnnotation>,
type_predicate: Option<TypePredicateAnnotation>,
body: StmtId,
doc: Option<DocComment>,
},
If {
condition: ExprId,
then_block: StmtId,
else_block: Option<StmtId>,
},
While {
condition: ExprId,
body: StmtId,
},
For {
init: Option<StmtId>,
condition: Option<ExprId>,
update: Option<StmtId>,
body: StmtId,
},
ForOf {
binding_kind: BindingKind,
name: Ident,
ty: Option<TypeAnnotation>,
iter: ExprId,
body: StmtId,
},
ForOfPattern {
binding_kind: BindingKind,
binding: Binding,
ty: Option<TypeAnnotation>,
iter: ExprId,
body: StmtId,
},
DoWhile {
body: StmtId,
condition: ExprId,
},
Switch {
discriminant: ExprId,
cases: Vec<SwitchCase>,
default: Option<SwitchDefault>,
},
Break,
Continue,
Return(Option<ExprId>),
Throw {
value: ExprId,
},
Try {
body: StmtId,
catches: Vec<CatchClause>,
finally: Option<StmtId>,
},
Expr(ExprId),
Block(Vec<StmtId>),
Assign {
target: Ident,
value: ExprId,
},
AssignField {
receiver: ExprId,
field_name: Ident,
value: ExprId,
},
AssignIndex {
receiver: ExprId,
index: ExprId,
value: ExprId,
},
CompoundAssign {
target: Ident,
op: BinOp,
op_span: Span,
value: ExprId,
},
CompoundAssignField {
receiver: ExprId,
field_name: Ident,
op: BinOp,
op_span: Span,
value: ExprId,
},
CompoundAssignIndex {
receiver: ExprId,
index: ExprId,
op: BinOp,
op_span: Span,
value: ExprId,
},
InterfaceDecl {
name: Ident,
generics: Vec<Ident>,
extends: Vec<TypeAnnotation>,
members: Vec<InterfaceMember>,
doc: Option<DocComment>,
},
ClassDecl {
name: Ident,
generics: Vec<Ident>,
extends: Option<TypeAnnotation>,
implements: Vec<TypeAnnotation>,
members: Vec<ClassMember>,
doc: Option<DocComment>,
},
EnumDecl {
name: Ident,
members: Vec<EnumMember>,
doc: Option<DocComment>,
},
TypeAliasDecl {
name: Ident,
generics: Vec<Ident>,
ty: TypeAnnotation,
doc: Option<DocComment>,
},
Import {
module: String,
module_span: Span,
kind: ImportKind,
doc: Option<DocComment>,
},
ExportFrom {
specs: Vec<ImportSpecifier>,
source: Option<(String, Span)>,
doc: Option<DocComment>,
},
}Variants§
Let
Const
LetPattern
Destructuring let. Eliminated by lower_patterns into plain Let stmts; never reaches the typechecker.
ConstPattern
ObjectRest
Rest binding from const { a, ...rest } = obj or its let form. name gets a narrowed type with exclude fields removed; codegen treats it like Const or Let.
Function
Fields
return_type: Option<TypeAnnotation>None when a type predicate is declared; exactly one of return_type / type_predicate is Some after parse.
type_predicate: Option<TypePredicateAnnotation>doc: Option<DocComment>If
While
For
C-style for loop. update is a StmtId so an assignment there is an assignment statement.
Fields
ForOf
ForOfPattern
Destructuring for-of head. Eliminated by lower_patterns; never reaches the typechecker.
DoWhile
Switch
No fallthrough — typechecker rejects a case body that doesn’t end in break or return.
Break
Continue
Return(Option<ExprId>)
Throw
Try
catches may be empty and finally optional, but at least one must appear.
Multiple catch clauses dispatch in declaration order on the thrown
value’s nominal class; the typechecker rejects unreachable arms.
Expr(ExprId)
Block(Vec<StmtId>)
Assign
AssignField
AssignIndex
CompoundAssign
target += value; etc. Lowered to Assign with a synthesized Binary; op_span anchors infer diagnostics.
CompoundAssignField
CompoundAssignIndex
InterfaceDecl
Interface declaration. Single declaration site per name; no reopening.
ClassDecl
Class declaration. Single inheritance via extends, structural implements.
generics is parsed and stored for forward-compat; generic classes are not yet
consumed downstream (classes.md non-goals).
Fields
extends: Option<TypeAnnotation>implements: Vec<TypeAnnotation>members: Vec<ClassMember>doc: Option<DocComment>EnumDecl
Enum declaration. No const enums, no computed members. value: None means auto-numbered at typecheck time.
TypeAliasDecl
Import
Top-level only; nested imports are a parse error.
ExportFrom
Re-export (export { a, b as c } from "./util"; or export { x };).
Top-level only. Parses in single-file but the typechecker gates it
until cross-module packages land. source is the from "…" module
path + span, or None for the bare export { x }; form.