feat: implement type-narrowing

* `in` narrowing
This commit is contained in:
Shunsuke Shibayama 2023-03-28 02:00:42 +09:00
parent 824075f7ee
commit fc3fe5de0c
6 changed files with 167 additions and 19 deletions

View file

@ -456,6 +456,10 @@ pub fn not(ty: Type) -> Type {
Type::Not(Box::new(ty))
}
pub fn guard(var: Variable, to: Type) -> Type {
Type::Guard(GuardType::new(var, to))
}
#[inline]
pub fn instanceof(t: Type) -> Constraint {
Constraint::new_type_of(t)