pub enum InferType {
}Expand description
Inference-time type representation.
Extends LogosType with:
InferType::Var— an unbound type variableInferType::Function— a function type (not needed in codegen)InferType::Unknown— propagated uncertainty (unifies with anything)
Variants§
Int
Float
Bool
Char
Byte
String
Unit
Nat
Duration
Date
Moment
Time
Span
Seq(Box<InferType>)
Map(Box<InferType>, Box<InferType>)
Set(Box<InferType>)
Option(Box<InferType>)
UserDefined(Symbol)
Var(TyVar)
Function(Vec<InferType>, Box<InferType>)
Unknown
Implementations§
Source§impl InferType
impl InferType
Sourcepub fn from_type_expr(ty: &TypeExpr<'_>, interner: &Interner) -> InferType
pub fn from_type_expr(ty: &TypeExpr<'_>, interner: &Interner) -> InferType
Convert a TypeExpr AST node to InferType.
Unlike LogosType::from_type_expr, this correctly handles
TypeExpr::Function { inputs, output } by producing
InferType::Function(...) instead of Unknown.
Sourcepub fn from_type_expr_with_params(
ty: &TypeExpr<'_>,
interner: &Interner,
type_params: &HashMap<Symbol, TyVar>,
) -> InferType
pub fn from_type_expr_with_params( ty: &TypeExpr<'_>, interner: &Interner, type_params: &HashMap<Symbol, TyVar>, ) -> InferType
Convert a TypeExpr to InferType, substituting generic type parameters.
When type_params maps a name like T to a TyVar, any TypeExpr::Primitive(T)
or TypeExpr::Named(T) in the expression produces InferType::Var(tv) instead
of Unknown. This is used for generic function signatures where T is a type
parameter, not a concrete type name.
Sourcepub fn from_field_type(
ty: &FieldType,
interner: &Interner,
type_params: &HashMap<Symbol, TyVar>,
) -> InferType
pub fn from_field_type( ty: &FieldType, interner: &Interner, type_params: &HashMap<Symbol, TyVar>, ) -> InferType
Convert a registry FieldType to InferType.
type_params maps generic type parameter names (e.g., T, U) to
type variable indices allocated by UnificationTable::fresh.
Sourcepub fn from_literal(lit: &Literal) -> InferType
pub fn from_literal(lit: &Literal) -> InferType
Infer InferType from a literal value.
Sourcepub fn from_type_name(name: &str) -> InferType
pub fn from_type_name(name: &str) -> InferType
Parse a LOGOS type name into InferType.
Sourcepub fn to_logos_name(&self) -> String
pub fn to_logos_name(&self) -> String
Human-readable type name in Logos terms, for error messages.
Sourcepub fn to_logos_type_ground(&self) -> LogosType
pub fn to_logos_type_ground(&self) -> LogosType
Convert a known-ground InferType to LogosType.
§Panics
Panics if called on a Var. Callers must [zonk] first.