mirror of
https://github.com/roc-lang/roc.git
synced 2024-09-20 23:37:56 +03:00
Don't re-report obligations that we know were seen elsewhere
This commit is contained in:
parent
6b9c1cb690
commit
bb14b649a2
@ -238,8 +238,10 @@ impl DeferredObligations {
|
||||
// Go through and attach generic "type does not implement ability" errors, if they were not
|
||||
// part of a larger context.
|
||||
for mia in incomplete_not_in_context.into_iter() {
|
||||
if let Err(unfulfilled) = obligation_cache.check_one(subs, mia) {
|
||||
if !reported_in_context.contains(&mia) {
|
||||
// If the obligation is already cached, we must have already reported it in another
|
||||
// context.
|
||||
if !obligation_cache.has_cached(mia) && !reported_in_context.contains(&mia) {
|
||||
if let Err(unfulfilled) = obligation_cache.check_one(subs, mia) {
|
||||
problems.push(TypeError::UnfulfilledAbility(unfulfilled.clone()));
|
||||
}
|
||||
}
|
||||
@ -274,6 +276,19 @@ impl ObligationCache<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
fn has_cached(&self, mia: MustImplementAbility) -> bool {
|
||||
match mia.typ {
|
||||
Obligated::Opaque(opaque) => self.impl_cache.contains_key(&ImplKey {
|
||||
opaque,
|
||||
ability: mia.ability,
|
||||
}),
|
||||
Obligated::Adhoc(_) => {
|
||||
// ad-hoc obligations are never cached
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn check_adhoc(&mut self, subs: &mut Subs, var: Variable, ability: Symbol) -> ObligationResult {
|
||||
// Not worth caching ad-hoc checks because variables are unlikely to be the same between
|
||||
// independent queries.
|
||||
|
@ -9109,10 +9109,6 @@ All branches in an `if` must have the same type!
|
||||
|
||||
Tip: `A` does not implement `Encoding`. Consider adding a custom
|
||||
implementation or `has Encode.Encoding` to the definition of `A`.
|
||||
|
||||
── INCOMPLETE ABILITY IMPLEMENTATION ───────────────────── /code/proj/Main.roc ─
|
||||
|
||||
The type `A` does not fully implement the ability `Encoding`.
|
||||
"###
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user