Struct erg_compiler::context::instantiate::TyVarCache
source · pub struct TyVarCache { /* private fields */ }
Expand description
Context for instantiating a quantified type
For example, cloning each type variable of quantified type ?T -> ?T
would result in ?1 -> ?2
.
To avoid this, an environment to store type variables is needed, which is TyVarCache
.
量化型をインスタンス化するための文脈
e.g. Array -> [(“T”: ?T(: Type)), (“N”: ?N(: Nat))]
FIXME: current implementation is wrong
It will not work unless the type variable is used with the same name as the definition.
Implementations§
source§impl TyVarCache
impl TyVarCache
pub fn new(level: usize, _ctx: &Context) -> Self
pub fn is_empty(&self) -> bool
pub fn merge(&mut self, outer: &Self)
pub fn purge(&mut self, other: &Self)
pub fn remove(&mut self, name: &str)
sourcepub fn warn_isolated_vars(&self, ctx: &Context)
pub fn warn_isolated_vars(&self, ctx: &Context)
Warn when a type does not need to be a type variable, such as |T| T -> Int
(it should be Obj -> Int
).
TODO: This warning is currently disabled because it raises a false warning in cases like |T|(x: T) -> (y: T) -> (x, y)
.
Trait Implementations§
source§impl Clone for TyVarCache
impl Clone for TyVarCache
source§fn clone(&self) -> TyVarCache
fn clone(&self) -> TyVarCache
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TyVarCache
impl Debug for TyVarCache
Auto Trait Implementations§
impl RefUnwindSafe for TyVarCache
impl Send for TyVarCache
impl Sync for TyVarCache
impl Unpin for TyVarCache
impl UnwindSafe for TyVarCache
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
Mutably borrows from an owned value. Read more