pub enum TypedExpr {
Show 25 variants
Int {
value: i64,
ty: QalaType,
span: Span,
},
Float {
value: f64,
ty: QalaType,
span: Span,
},
Byte {
value: u8,
ty: QalaType,
span: Span,
},
Str {
value: String,
ty: QalaType,
span: Span,
},
Bool {
value: bool,
ty: QalaType,
span: Span,
},
Ident {
name: String,
ty: QalaType,
span: Span,
},
Paren {
inner: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Tuple {
elems: Vec<TypedExpr>,
ty: QalaType,
span: Span,
},
ArrayLit {
elems: Vec<TypedExpr>,
ty: QalaType,
span: Span,
},
ArrayRepeat {
value: Box<TypedExpr>,
count: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
StructLit {
name: String,
fields: Vec<TypedFieldInit>,
ty: QalaType,
span: Span,
},
FieldAccess {
obj: Box<TypedExpr>,
name: String,
ty: QalaType,
span: Span,
},
MethodCall {
receiver: Box<TypedExpr>,
name: String,
args: Vec<TypedExpr>,
ty: QalaType,
span: Span,
},
Call {
callee: Box<TypedExpr>,
args: Vec<TypedExpr>,
ty: QalaType,
span: Span,
},
Index {
obj: Box<TypedExpr>,
index: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Try {
expr: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Unary {
op: UnaryOp,
operand: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Binary {
op: BinOp,
lhs: Box<TypedExpr>,
rhs: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Range {
start: Option<Box<TypedExpr>>,
end: Option<Box<TypedExpr>>,
inclusive: bool,
ty: QalaType,
span: Span,
},
Pipeline {
lhs: Box<TypedExpr>,
call: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Comptime {
body: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Block {
block: TypedBlock,
ty: QalaType,
span: Span,
},
Match {
scrutinee: Box<TypedExpr>,
arms: Vec<TypedMatchArm>,
ty: QalaType,
span: Span,
},
OrElse {
expr: Box<TypedExpr>,
fallback: Box<TypedExpr>,
ty: QalaType,
span: Span,
},
Interpolation {
parts: Vec<TypedInterpPart>,
ty: QalaType,
span: Span,
},
}Expand description
a typed expression. mirror of ast::Expr with a resolved QalaType
annotation on every variant.
nothing is desugared: TypedExpr::Pipeline stays a pipeline (not
f(x, a)), TypedExpr::Interpolation stays a parts list (not a +
chain), TypedExpr::Match and TypedExpr::Block produce values
directly. the rule is the same as for the untyped AST – the typechecker
only types; codegen lowers.
every recursive position is a Box<TypedExpr>; the variant-level ty
field is the design choice over a wrapper struct (TypedExpr { kind, span, ty }) – per-variant means TypedExpr::ty is one exhaustive match that
the compiler enforces.
Variants§
Int
an integer literal with its resolved type (QalaType::I64).
Float
a float literal with its resolved type (QalaType::F64).
Byte
a byte literal with its resolved type (QalaType::Byte).
Str
a string literal with its resolved type (QalaType::Str).
Bool
a boolean literal with its resolved type (QalaType::Bool).
Ident
an identifier reference resolved to its bound type.
Paren
( inner ) – a parenthesized expression. semantically transparent; the
resolved type is the inner’s type.
Tuple
( e1, e2, ... ) – a tuple. resolved type is
QalaType::Tuple of the element types.
ArrayLit
[ e1, e2, ... ] – an array literal. resolved type is
QalaType::Array with Some(n) length matching elems.len().
ArrayRepeat
[ value; count ] – the repeat form of an array literal.
StructLit
Name { field: e, ... } – a struct literal. resolved type is
QalaType::Named of the struct.
FieldAccess
obj.name – field access. distinct from TypedExpr::MethodCall:
this is the form with no ( ... ) after the .name. resolved type is
the field’s type.
MethodCall
receiver.name(args) – a method call. distinct from a field access
followed by a call; the typechecker resolves it to the
fn Type.name(self, ...) declaration. resolved type is the method’s
return type.
Call
callee(args) – a call expression. resolved type is the callee’s
return type.
Index
obj[index] – an index expression. resolved type is the element type
of the array.
Try
expr? – error propagation. resolved type is the Ok payload (for
Result<T, E>) or the Some payload (for Option<T>).
Unary
a unary-operator application: !operand or -operand. resolved type
is determined by the operand and the operator.
Binary
a binary-operator application. resolved type is determined by the
operator (arithmetic: matches the operand type; comparison and equality:
bool; &&/||: bool). the or fallback is not here – it is
TypedExpr::OrElse.
Range
start .. end or start ..= end. resolved type is the iterable type
the range stands for.
Fields
Pipeline
lhs |> call – the pipeline operator. NOT desugared in the typed AST
either; desugaring is Phase 4 codegen’s job. resolved type is the call’s
return type.
Comptime
comptime body – compile-time evaluated. resolved type is the body’s
type (the typechecker only types it; evaluation is codegen).
Block
{ ...; trailing } used as an expression. resolved type is the block’s
trailing-value type (or void); duplicated at this level so the
uniform TypedExpr::ty accessor reads from a variant field rather
than peeking into the TypedBlock.
Match
match scrutinee { arm, ... }. NOT desugared. resolved type is the
common type of all arm bodies; exhaustiveness is checked by the
typechecker against the scrutinee’s enum type.
OrElse
expr or fallback – the inline fallback for a Result/Option. NOT
desugared. resolved type is the T of Result<T, E> / Option<T>.
Interpolation
a string with {expr} interpolations. NOT desugared to a + chain;
the conversion-and-concatenation happens in Phase 4 codegen. resolved
type is QalaType::Str.