Skip to main content

Type

Enum Type 

Source
pub enum Type {
Show 15 variants Simple(SimpleKind), Compound { kind: CompoundKind, args: Vec<Type>, writable: bool, }, Nominal { id: Symbol, params: Vec<Type>, writable: bool, }, 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

Fields

§args: Vec<Type>
§writable: bool

Write permission through this reference. Only Slice, Map, and Ref can carry it.

§

Nominal

Fields

§params: Vec<Type>
§writable: bool
§

ImportNamespace(EcoString)

Package 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 package’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

Fields

§body: Box<Type>
§

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.

Fields

§length: u64
§element: Box<Type>
§

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

Source

pub fn stringify(&self) -> String

Source

pub fn stringify_pair(first: &Self, second: &Self) -> (String, String)

Source§

impl Type

Source

pub fn compound(kind: CompoundKind, args: Vec<Type>) -> Type

Source

pub fn qualified_compound( kind: CompoundKind, args: Vec<Type>, writable: bool, ) -> Type

Source

pub fn contains_write_permission(&self) -> bool

Whether a write permission appears anywhere in this type.

Source

pub fn contains_type_parameter(&self) -> bool

Whether a type parameter appears anywhere in this type.

Source

pub fn is_writable(&self) -> bool

Source

pub fn make_writable(self) -> Type

Source

pub fn writable_clone_result(&self) -> Type

A deep clone’s type: fresh writable storage at every built-in container layer, nominal elements copied shallowly.

Source

pub fn shallow_demoted(&self) -> Type

This type with its own write permission removed, type arguments untouched.

Source

pub fn demotion_changes(&self) -> bool

Whether demoted would return a different type. Must mirror demoted.

Source

pub fn demoted(&self) -> Type

Source

pub fn function( params: Vec<FunctionParameter>, bounds: Vec<Bound>, return_type: Box<Type>, ) -> Type

Source

pub fn int() -> Type

Source

pub fn string() -> Type

Source

pub fn bool() -> Type

Source

pub fn unit() -> Type

Source§

impl Type

Source

pub fn uninferred() -> Self

Source

pub fn is_uninferred(&self) -> bool

Source

pub fn ignored() -> Self

Source

pub fn get_type_params(&self) -> Option<&[Type]>

Source

pub fn children(&self) -> Vec<&Type>

Direct child types, for read-only walks. Excludes Function.bounds.

Source§

impl Type

Source

pub fn get_function_ret(&self) -> Option<&Type>

Source

pub fn is_stringer_signature(&self) -> bool

Source

pub fn is_equals_signature(&self) -> bool

Source

pub fn is_equals_bound_signature(&self, param_name: &str) -> bool

Source

pub fn equals_receiver_vars( &self, owner_id: &str, arity: usize, ) -> Option<Vec<EcoString>>

Source

pub fn has_name(&self, name: &str) -> bool

Source

pub fn get_qualified_id(&self) -> Option<&str>

Source

pub fn is_result(&self) -> bool

Source

pub fn is_option(&self) -> bool

Source

pub fn is_partial(&self) -> bool

Source

pub fn is_unit(&self) -> bool

Source

pub fn tuple_arity(&self) -> Option<usize>

Source

pub fn is_tuple(&self) -> bool

Source

pub fn array_len(&self) -> Option<u64>

Source

pub fn as_import_namespace(&self) -> Option<&str>

Source

pub fn as_compound(&self) -> Option<(CompoundKind, &[Type])>

Source

pub fn is_native(&self, kind: CompoundKind) -> bool

Source

pub fn is_ref(&self) -> bool

Source

pub fn is_slice(&self) -> bool

Source

pub fn is_map(&self) -> bool

Source

pub fn is_channel(&self) -> bool

Source

pub fn is_receiver_placeholder(&self) -> bool

Source

pub fn is_unknown(&self) -> bool

Source

pub fn is_receiver(&self) -> bool

Source

pub fn is_ignored(&self) -> bool

Source

pub fn is_placeholder(&self) -> bool

Source

pub fn is_variadic(&self) -> Option<Type>

Source

pub fn is_string(&self) -> bool

Source

pub fn is_byte_slice(&self) -> bool

Source

pub fn as_simple(&self) -> Option<SimpleKind>

Source

pub fn is_simple(&self, kind: SimpleKind) -> bool

Source

pub fn is_boolean(&self) -> bool

Source

pub fn is_rune(&self) -> bool

Source

pub fn is_float(&self) -> bool

Source

pub fn is_variable(&self) -> bool

Source

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.

Source

pub fn is_numeric(&self) -> bool

Source

pub fn is_complex(&self) -> bool

Source

pub fn is_unsigned_int(&self) -> bool

Source

pub fn is_never(&self) -> bool

Source

pub fn is_error(&self) -> bool

Source

pub fn contains_error(&self) -> bool

Source

pub fn has_unbound_variables(&self) -> bool

Source

pub fn collect_unbound_variables(&self, out: &mut Vec<TypeVarId>)

Source

pub fn remove_found_type_names(&self, names: &mut HashSet<EcoString>)

Source§

impl Type

Source

pub fn get_name(&self) -> Option<&str>

Source

pub fn wraps(&self, name: &str, inner: &Type) -> bool

Source

pub fn get_function_params(&self) -> Option<&[FunctionParameter]>

Source

pub fn param_count(&self) -> usize

Source

pub fn with_replaced_first_param(&self, new_first: &Type) -> Type

Source

pub fn get_bounds(&self) -> &[Bound]

Source

pub fn get_qualified_name(&self) -> Option<Symbol>

Source

pub fn inner(&self) -> Option<Type>

Source

pub fn ok_type(&self) -> Type

Source

pub fn err_type(&self) -> Type

Source§

impl Type

Source

pub fn unwrap_forall(&self) -> &Type

Source

pub fn as_function_type(&self) -> Option<&FunctionType>

Source

pub fn strip_refs(&self) -> Type

Source

pub fn with_receiver_placeholder(self) -> Type

Source

pub fn remove_vars(types: &[&Type]) -> (Vec<Type>, Vec<EcoString>)

Source

pub fn contains_type(&self, target: &Type) -> bool

Source§

impl Type

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Type

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Type

Source§

impl Hash for Type

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Type

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToEcoString for T
where T: Display + ?Sized,

Source§

fn to_eco_string(&self) -> EcoString

Converts the given value to an EcoString.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.