pub enum Type {
Simple(SimpleKind),
Compound {
kind: CompoundKind,
args: Vec<Type>,
},
Nominal {
id: Symbol,
params: Vec<Type>,
underlying_ty: Option<Box<Type>>,
},
ImportNamespace(EcoString),
Function {
params: Vec<Type>,
param_mutability: Vec<bool>,
bounds: Vec<Bound>,
return_type: Box<Type>,
},
Var {
id: TypeVarId,
hint: Option<EcoString>,
},
Forall {
vars: Vec<EcoString>,
body: Box<Type>,
},
Parameter(EcoString),
Never,
Tuple(Vec<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
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.
Forall
Parameter(EcoString)
Never
Tuple(Vec<Type>)
Error
Poison type returned after an error has been reported. Unifies with everything silently, preventing cascading diagnostics.
ReceiverPlaceholder
Sentinel occupying the self 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 simple(kind: SimpleKind) -> Type
pub fn compound(kind: CompoundKind, args: Vec<Type>) -> Type
pub fn int() -> Type
pub fn string() -> Type
pub fn bool() -> Type
pub fn unit() -> Type
pub fn float64() -> Type
pub fn rune() -> Type
pub fn byte() -> Type
Source§impl Type
impl Type
pub fn get_function_ret(&self) -> Option<&Type>
pub fn has_name(&self, name: &str) -> bool
pub fn get_qualified_id(&self) -> Option<&str>
pub fn get_underlying(&self) -> Option<&Type>
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 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 resolves_to_unknown(&self) -> bool
pub fn contains_unknown(&self) -> bool
pub fn is_receiver(&self) -> bool
pub fn is_ignored(&self) -> bool
pub fn is_variadic(&self) -> Option<Type>
pub fn is_string(&self) -> bool
pub fn is_slice_of_simple(&self, element: SimpleKind) -> bool
pub fn is_slice_of(&self, element_name: &str) -> bool
pub fn is_byte_slice(&self) -> bool
pub fn is_rune_slice(&self) -> bool
pub fn is_byte_or_rune_slice(&self) -> bool
pub fn has_underlying_rune(&self) -> bool
pub fn has_underlying_byte(&self) -> bool
pub fn has_byte_or_rune_slice_underlying(&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_float64(&self) -> bool
pub fn is_float32(&self) -> bool
pub fn is_float(&self) -> bool
pub fn is_variable(&self) -> bool
pub fn is_type_var(&self) -> bool
pub fn is_numeric(&self) -> bool
pub fn is_ordered(&self) -> bool
Sourcepub fn satisfies_ordered_constraint(&self) -> bool
pub fn satisfies_ordered_constraint(&self) -> bool
True for Go’s cmp.Ordered set: ints, floats, strings, and named aliases over them.
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 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<&[Type]>
pub fn param_count(&self) -> usize
pub fn get_param_mutability(&self) -> &[bool]
pub fn with_replaced_first_param(&self, new_first: &Type) -> Type
pub fn get_bounds(&self) -> &[Bound]
pub fn get_qualified_name(&self) -> 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 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 underlying_numeric_type(&self) -> Option<Type>
pub fn has_underlying_numeric_type(&self) -> bool
pub fn numeric_family(&self) -> Option<NumericFamily>
pub fn is_numeric_compatible_with(&self, other: &Type) -> bool
pub fn is_aliased_numeric_type(&self) -> bool
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.