mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 02:39:20 +00:00
feat: implement type-narrowing
* `in` narrowing
This commit is contained in:
parent
824075f7ee
commit
fc3fe5de0c
6 changed files with 167 additions and 19 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue