mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 18:58:30 +00:00
fix: type narrowing bug
This commit is contained in:
parent
d881a6ae3e
commit
242171b280
2 changed files with 9 additions and 3 deletions
|
@ -2952,10 +2952,11 @@ impl<A: ASTBuildable> GenericASTLowerer<A> {
|
|||
}
|
||||
};
|
||||
if let Some(casted) = casted {
|
||||
if expr.ref_t().is_projection() || self.module.context.subtype_of(&casted, expr.ref_t())
|
||||
{
|
||||
// e.g. casted == {x: Obj | x != None}, expr: Int or NoneType => intersec == Int
|
||||
let intersec = self.module.context.intersection(expr.ref_t(), &casted);
|
||||
if expr.ref_t().is_projection() || intersec != Type::Never {
|
||||
if let Some(ref_mut_t) = expr.ref_mut_t() {
|
||||
*ref_mut_t = casted;
|
||||
*ref_mut_t = intersec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue