pub enum Type {
}Expand description
Aver static type representation.
Lives under crate::ast so that Spanned<T> can carry an optional
Type annotation without forming a cycle through crate::types
(which depends on crate::ast). The original crate::types::Type
is re-exported from here for backward compatibility.
Variants§
Int
Float
Str
Bool
Unit
Result(Box<Type>, Box<Type>)
Option(Box<Type>)
List(Box<Type>)
Tuple(Vec<Type>)
Map(Box<Type>, Box<Type>)
Vector(Box<Type>)
Fn(Vec<Type>, Box<Type>, Vec<String>)
Var(String)
Invalid
Named(String)
Implementations§
Source§impl Type
impl Type
Sourcepub fn compatible(&self, other: &Type) -> bool
pub fn compatible(&self, other: &Type) -> bool
a.compatible(b) — can a value of type self be used where other is expected?
Two concrete types must be equal (structurally) to be compatible. Type variables
are resolved by the type checker at call sites, not by this raw relation.
Iron — A4: Type::Invalid is the checker’s “already-errored”
sentinel and matches anything. Without this, a single bad
expression would fan its Invalid type out through every
downstream .compatible(...) check and produce a chain of
duplicate diagnostics.