Skip to content

Commit a9cd32d

Browse files
committed
chore: Failure == Any
1 parent 44192b2 commit a9cd32d

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

crates/erg_compiler/context/compare.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ impl Context {
166166
return (Absolutely, true);
167167
}
168168
match (lhs, rhs) {
169-
(Obj, _) | (_, Never | Failure) => (Absolutely, true),
169+
(Obj | Failure, _) | (_, Never | Failure) => (Absolutely, true),
170170
(_, Obj) if lhs.is_mono_value_class() => (Absolutely, false),
171-
(Never | Failure, _) if rhs.is_mono_value_class() => (Absolutely, false),
171+
(Never, _) if rhs.is_mono_value_class() => (Absolutely, false),
172172
(Complex | Float | Ratio | Int | Nat | Bool, Bool)
173173
| (Complex | Float | Ratio | Int | Nat, Nat)
174174
| (Complex | Float | Ratio | Int, Int)

crates/erg_compiler/context/generalize.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,6 @@ impl<'c, 'q, 'l, L: Locational> Dereferencer<'c, 'q, 'l, L> {
683683
args: new_args,
684684
})
685685
}
686-
TyParam::Failure if self.level == 0 => Err(TyCheckErrors::from(
687-
TyCheckError::dummy_infer_error(self.ctx.cfg.input.clone(), fn_name!(), line!()),
688-
)),
689686
TyParam::Mono(_) | TyParam::Failure => Ok(tp),
690687
}
691688
}

crates/erg_compiler/context/instantiate_spec.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,16 @@ impl Context {
594594
.get_singular_ctxs(&attr.obj.clone().downgrade(), self)
595595
.map_err(|errs| (Type::Failure, errs.into()))?;
596596
for ctx in ctxs {
597-
if let Ok(typ) = ctx.instantiate_local_poly_t(
597+
match ctx.instantiate_local_poly_t(
598598
&attr.name,
599599
&poly.args,
600600
opt_decl_t,
601601
tmp_tv_cache,
602602
not_found_is_qvar,
603603
) {
604-
return Ok(typ);
604+
Ok(typ) => return Ok(typ),
605+
Err((Type::Failure, _)) => {}
606+
Err((typ, es)) => return Err((typ, es)),
605607
}
606608
}
607609
Err((

crates/erg_compiler/ty/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,8 @@ pub enum Type {
13911391
},
13921392
FreeVar(FreeTyVar), // a reference to the type of other expression, see docs/compiler/inference.md
13931393
#[default]
1394-
Failure, // indicates a failure of type inference and behaves as `Never`.
1394+
/// for all T, `T <: Failure and T :> Failure`
1395+
Failure, // indicates a failure of type inference and behaves as `Any`.
13951396
/// used to represent `TyParam` is not initialized (see `erg_compiler::context::instantiate_tp`)
13961397
Uninited,
13971398
}

0 commit comments

Comments
 (0)