ExpressionInference class
Defined in module l0_check_expr (l0_check_expr.py).
Mutually recursive expression inference over explicit semantic dependencies.
Public static attributes
- static TypeCompatibility compat
- static ExpressionLiveness liveness
- static SemanticLookup lookup
- static CheckerState state
Protected functions
- auto _infer_type_expr(self, TypeExpr expr) -> Type|None
- TypeExpr is only valid as an argument to type-accepting intrinsics.
- auto _infer_expr(self, Expr|None expr, *Type|None widening_type = None, str context_code = "TYP-0319", str context_descriptor = "expression") -> Type|None
- Infer the type of an expression.
- auto _infer_var_ref(self, VarRef expr) -> Type|None
- Infer type for a variable reference.
- auto _infer_unary(self, UnaryOp expr) -> Type|None
- Infer type for a unary operation.
- auto _infer_binary(self, BinaryOp expr) -> Type|None
- Infer type for a binary operation.
- auto _binary_expect_both_int(self, BinaryOp expr, Type|None left, Type|None right, Type|None result) -> Type|None
- Check that both operands of a binary op are int-assignable.
- auto _binary_expect_both_bool(self, BinaryOp expr, Type|None left, Type|None right, Type|None result) -> Type|None
- Check that both operands of a binary op are bool.
- auto _binary_equality(self, BinaryOp expr, Type|None left, Type|None right) -> Type|None
- Infer type for equality/inequality comparison.
- auto _try_infer_intrinsic(self, CallExpr expr) -> Type|None
- Handle compiler intrinsics calls.
- auto _infer_sizeof_intrinsic(self, CallExpr expr) -> Type
- Handle sizeof(T) or sizeof(expr) intrinsic.
- auto _infer_ord_intrinsic(self, CallExpr expr) -> Type
- Handle ord(enum_value) intrinsic - returns 0-based ordinal of enum variant.
- auto _infer_call(self, CallExpr expr) -> Type|None
- Infer type for a function or constructor call.
- auto _infer_struct_constructor(self, CallExpr expr, Symbol sym) -> Type|None
- Infer type for a struct constructor call.
- auto _infer_variant_constructor(self, CallExpr expr, Symbol sym) -> Type|None
- Infer type for an enum variant constructor call.
- auto _infer_index(self, IndexExpr expr) -> Type|None
- Infer type for an indexing expression.
- auto _infer_field_access(self, FieldAccessExpr expr) -> Type|None
- Infer type for a field access expression.
- auto _infer_cast(self, CastExpr expr) -> Type|None
- Infer type for a cast expression and validate compatibility.
- auto _infer_try(self, TryExpr expr) -> Type|None
- Infer type for a '?' try operator expression.
- auto _infer_new(self, NewExpr expr) -> Type|None
- Infer type for a 'new' heap allocation expression.
Function documentation
Type|None l0_check_expr:: ExpressionInference:: _infer_expr(self,
Expr|None expr,
*Type|None widening_type = None,
str context_code = "TYP-0319",
str context_descriptor = "expression") protected
Infer the type of an expression.
| Parameters | |
|---|---|
| expr | The expression to type-check. |
| widening_type | Optional expected type for context-sensitive checking. |
| context_code | Diagnostic code for type mismatch. |
| context_descriptor | Description of context for diagnostic. |
| Returns | The resolved Type of the expression, or None on error. |