pub enum Type {
Show 15 variants
Simple(SimpleKind),
Compound {
kind: CompoundKind,
args: Vec<Type>,
},
Nominal {
id: Symbol,
params: Vec<Type>,
},
ImportNamespace(EcoString),
Function(Arc<FunctionType>),
Var {
id: TypeVarId,
hint: Option<EcoString>,
},
Uninferred,
Ignored,
Forall {
vars: Vec<EcoString>,
body: Box<Type>,
},
Parameter(EcoString),
Never,
Tuple(Vec<Type>),
Array {
length: u64,
element: Box<Type>,
},
Error,
ReceiverPlaceholder,
}Variants§
Simple(SimpleKind)
Compound
Nominal
ImportNamespace(EcoString)
Module namespace handle. Produced by imports (e.g. import http "net/http"
produces an ImportNamespace("go:net/http") on the local identifier).
Dot-access on this type resolves to the module’s exports.
Function(Arc<FunctionType>)
Var
Type variable handle. Binding state lives in a TypeEnv owned by the
checker; the inline hint is display metadata set at allocation time
so Display/Debug work without env access.
Uninferred
Placeholder on syntax that has not entered type inference yet.
Ignored
Expected type for an expression whose value is intentionally discarded.
Forall
Parameter(EcoString)
Never
Tuple(Vec<Type>)
Array
Fixed-size array Array<T, N>, lowered to Go [N]T. The length is part
of the type, so different-length arrays never unify.
Error
Poison type returned after an error has been reported. Unifies with everything silently, preventing cascading diagnostics.
ReceiverPlaceholder
Sentinel occupying the receiver slot of an interface method type.
Unifies silently so an implementing type’s receiver does not conflict
with the abstract method shape. Previously encoded as
Constructor { id: "**nominal.__receiver__" }.
Implementations§
Source§impl Type
impl Type
pub fn uninferred() -> Self
pub fn is_uninferred(&self) -> bool
pub fn ignored() -> Self
pub fn get_type_params(&self) -> Option<&[Type]>
Source§impl Type
impl Type
pub fn get_function_ret(&self) -> Option<&Type>
pub fn is_stringer_signature(&self) -> bool
pub fn is_equals_signature(&self) -> bool
pub fn is_equals_bound_signature(&self, param_name: &str) -> bool
pub fn equals_receiver_vars( &self, owner_id: &str, arity: usize, ) -> Option<Vec<EcoString>>
pub fn has_name(&self, name: &str) -> bool
pub fn get_qualified_id(&self) -> Option<&str>
pub fn is_result(&self) -> bool
pub fn is_option(&self) -> bool
pub fn is_partial(&self) -> bool
pub fn is_unit(&self) -> bool
pub fn tuple_arity(&self) -> Option<usize>
pub fn is_tuple(&self) -> bool
pub fn array_len(&self) -> Option<u64>
pub fn as_import_namespace(&self) -> Option<&str>
pub fn as_compound(&self) -> Option<(CompoundKind, &[Type])>
pub fn is_native(&self, kind: CompoundKind) -> bool
pub fn is_ref(&self) -> bool
pub fn is_slice(&self) -> bool
pub fn is_map(&self) -> bool
pub fn is_channel(&self) -> bool
pub fn is_receiver_placeholder(&self) -> bool
pub fn is_unknown(&self) -> bool
pub fn is_receiver(&self) -> bool
pub fn is_ignored(&self) -> bool
pub fn is_placeholder(&self) -> bool
pub fn is_variadic(&self) -> Option<Type>
pub fn is_string(&self) -> bool
pub fn is_byte_slice(&self) -> bool
pub fn as_simple(&self) -> Option<SimpleKind>
pub fn is_simple(&self, kind: SimpleKind) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_rune(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_variable(&self) -> bool
Sourcepub fn is_structural_alias_body(&self) -> bool
pub fn is_structural_alias_body(&self) -> bool
A transparent alias over this keeps its name, wrapped in a Nominal
that unification peels back to it.
pub fn is_numeric(&self) -> bool
pub fn is_complex(&self) -> bool
pub fn is_unsigned_int(&self) -> bool
pub fn is_never(&self) -> bool
pub fn is_error(&self) -> bool
pub fn contains_error(&self) -> bool
pub fn has_unbound_variables(&self) -> bool
pub fn collect_unbound_variables(&self, out: &mut Vec<TypeVarId>)
pub fn remove_found_type_names(&self, names: &mut HashSet<EcoString>)
Source§impl Type
impl Type
pub fn get_name(&self) -> Option<&str>
pub fn wraps(&self, name: &str, inner: &Type) -> bool
pub fn get_function_params(&self) -> Option<&[FunctionParameter]>
pub fn param_count(&self) -> usize
pub fn with_replaced_first_param(&self, new_first: &Type) -> Type
pub fn get_bounds(&self) -> &[Bound]
pub fn get_qualified_name(&self) -> Option<Symbol>
pub fn inner(&self) -> Option<Type>
pub fn ok_type(&self) -> Type
pub fn err_type(&self) -> Type
Source§impl Type
impl Type
pub fn unwrap_forall(&self) -> &Type
pub fn as_function_type(&self) -> Option<&FunctionType>
pub fn strip_refs(&self) -> Type
pub fn with_receiver_placeholder(self) -> Type
pub fn remove_vars(types: &[&Type]) -> (Vec<Type>, Vec<EcoString>)
pub fn contains_type(&self, target: &Type) -> bool
Source§impl Type
impl Type
pub fn numeric_family(&self) -> Option<NumericFamily>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Type
impl RefUnwindSafe for Type
impl Send for Type
impl Sync for Type
impl Unpin for Type
impl UnsafeUnpin for Type
impl UnwindSafe for Type
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,
Source§impl<T> ToEcoString for T
impl<T> ToEcoString for T
Source§fn to_eco_string(&self) -> EcoString
fn to_eco_string(&self) -> EcoString
EcoString.