Enum InferType
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
Rational
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§
§impl InferType
impl InferType
pub 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.
pub 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.
pub 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.
pub fn from_literal(lit: &Literal) -> InferType
pub fn from_literal(lit: &Literal) -> InferType
Infer InferType from a literal value.
pub fn from_type_name(name: &str) -> InferType
pub fn from_type_name(name: &str) -> InferType
Parse a LOGOS type name into InferType.
pub fn to_logos_name(&self) -> String
pub fn to_logos_name(&self) -> String
Human-readable type name in Logos terms, for error messages.
pub 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.
Trait Implementations§
impl StructuralPartialEq for InferType
Auto Trait Implementations§
impl Freeze for InferType
impl RefUnwindSafe for InferType
impl Send for InferType
impl Sync for InferType
impl Unpin for InferType
impl UnsafeUnpin for InferType
impl UnwindSafe for InferType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.