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 uninferred() -> Self
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 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 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_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.