mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-02 11:22:19 +00:00
Remove problems from error type API surface
This commit is contained in:
parent
b6322ff883
commit
09748aec48
5 changed files with 32 additions and 45 deletions
|
@ -191,8 +191,7 @@ impl ObligationCache {
|
|||
// Demote the bad variable that exposed this problem to an error, both so
|
||||
// that we have an ErrorType to report and so that codegen knows to deal
|
||||
// with the error later.
|
||||
let (error_type, _moar_ghosts_n_stuff) =
|
||||
subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
let error_type = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
problems.push(TypeError::BadExprMissingAbility(
|
||||
region,
|
||||
category,
|
||||
|
@ -209,8 +208,7 @@ impl ObligationCache {
|
|||
// Demote the bad variable that exposed this problem to an error, both so
|
||||
// that we have an ErrorType to report and so that codegen knows to deal
|
||||
// with the error later.
|
||||
let (error_type, _moar_ghosts_n_stuff) =
|
||||
subs.var_to_error_type(var, Polarity::OF_PATTERN);
|
||||
let error_type = subs.var_to_error_type(var, Polarity::OF_PATTERN);
|
||||
problems.push(TypeError::BadPatternMissingAbility(
|
||||
region,
|
||||
category,
|
||||
|
@ -311,15 +309,14 @@ impl ObligationCache {
|
|||
})) => Some(if failure_var == var {
|
||||
UnderivableReason::SurfaceNotDerivable(context)
|
||||
} else {
|
||||
let (error_type, _skeletons) =
|
||||
subs.var_to_error_type(failure_var, Polarity::OF_VALUE);
|
||||
let error_type = subs.var_to_error_type(failure_var, Polarity::OF_VALUE);
|
||||
UnderivableReason::NestedNotDerivable(error_type, context)
|
||||
}),
|
||||
None => Some(UnderivableReason::NotABuiltin),
|
||||
};
|
||||
|
||||
if let Some(underivable_reason) = opt_underivable {
|
||||
let (error_type, _skeletons) = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
let error_type = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
|
||||
Err(Unfulfilled::AdhocUnderivable {
|
||||
typ: error_type,
|
||||
|
|
|
@ -2013,7 +2013,7 @@ fn check_ability_specialization(
|
|||
// Commit so that the bad signature and its error persists in subs.
|
||||
subs.commit_snapshot(snapshot);
|
||||
|
||||
let (_typ, _problems) =
|
||||
let _typ =
|
||||
subs.var_to_error_type(symbol_loc_var.value, Polarity::OF_VALUE);
|
||||
|
||||
let problem = TypeError::WrongSpecialization {
|
||||
|
@ -2034,7 +2034,7 @@ fn check_ability_specialization(
|
|||
// Commit so that `var` persists in subs.
|
||||
subs.commit_snapshot(snapshot);
|
||||
|
||||
let (typ, _problems) = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
let typ = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
|
||||
let problem = TypeError::StructuralSpecialization {
|
||||
region: symbol_loc_var.region,
|
||||
|
@ -2056,9 +2056,9 @@ fn check_ability_specialization(
|
|||
// so we can have two separate error types.
|
||||
subs.rollback_to(snapshot);
|
||||
|
||||
let (expected_type, _problems) =
|
||||
let expected_type =
|
||||
subs.var_to_error_type(root_signature_var, Polarity::OF_VALUE);
|
||||
let (actual_type, _problems) =
|
||||
let actual_type =
|
||||
subs.var_to_error_type(symbol_loc_var.value, Polarity::OF_VALUE);
|
||||
|
||||
let reason = Reason::GeneralizedAbilityMemberSpecialization {
|
||||
|
@ -3492,7 +3492,7 @@ fn circular_error(
|
|||
loc_var: &Loc<Variable>,
|
||||
) {
|
||||
let var = loc_var.value;
|
||||
let (error_type, _) = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
let error_type = subs.var_to_error_type(var, Polarity::OF_VALUE);
|
||||
let problem = TypeError::CircularType(loc_var.region, symbol, error_type);
|
||||
|
||||
subs.set_content(var, Content::Error);
|
||||
|
|
|
@ -2041,11 +2041,7 @@ impl Subs {
|
|||
explicit_substitute(self, x, y, z, &mut seen)
|
||||
}
|
||||
|
||||
pub fn var_to_error_type(
|
||||
&mut self,
|
||||
var: Variable,
|
||||
observed_pol: Polarity,
|
||||
) -> (ErrorType, Vec<Problem>) {
|
||||
pub fn var_to_error_type(&mut self, var: Variable, observed_pol: Polarity) -> ErrorType {
|
||||
self.var_to_error_type_contextual(var, ErrorTypeContext::None, observed_pol)
|
||||
}
|
||||
|
||||
|
@ -2054,7 +2050,7 @@ impl Subs {
|
|||
var: Variable,
|
||||
context: ErrorTypeContext,
|
||||
observed_pol: Polarity,
|
||||
) -> (ErrorType, Vec<Problem>) {
|
||||
) -> ErrorType {
|
||||
let names = get_var_names(self, var, ImMap::default());
|
||||
let mut taken = MutSet::default();
|
||||
|
||||
|
@ -2069,7 +2065,7 @@ impl Subs {
|
|||
recursive_tag_unions_seen: Vec::new(),
|
||||
};
|
||||
|
||||
(var_to_err_type(self, &mut state, var, observed_pol), vec![])
|
||||
var_to_err_type(self, &mut state, var, observed_pol)
|
||||
}
|
||||
|
||||
pub fn len(&self) -> usize {
|
||||
|
|
|
@ -419,25 +419,20 @@ fn unify_help<M: MetaCollector>(
|
|||
ErrorTypeContext::None
|
||||
};
|
||||
|
||||
let (type1, mut problems) =
|
||||
env.subs
|
||||
let type1 = env
|
||||
.subs
|
||||
.var_to_error_type_contextual(var1, error_context, observed_pol);
|
||||
let (type2, problems2) =
|
||||
env.subs
|
||||
let type2 = env
|
||||
.subs
|
||||
.var_to_error_type_contextual(var2, error_context, observed_pol);
|
||||
|
||||
problems.extend(problems2);
|
||||
|
||||
env.subs.union(var1, var2, Content::Error.into());
|
||||
|
||||
if !problems.is_empty() {
|
||||
Unified::BadType(vars, problems.remove(0))
|
||||
} else {
|
||||
let do_not_implement_ability = mismatches
|
||||
.into_iter()
|
||||
.filter_map(|mismatch| match mismatch {
|
||||
Mismatch::DoesNotImplementAbiity(var, ab) => {
|
||||
let (err_type, _new_problems) =
|
||||
let err_type =
|
||||
env.subs
|
||||
.var_to_error_type_contextual(var, error_context, observed_pol);
|
||||
Some((err_type, ab))
|
||||
|
@ -449,7 +444,6 @@ fn unify_help<M: MetaCollector>(
|
|||
Unified::Failure(vars, type1, type2, do_not_implement_ability)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
|
|
|
@ -83,7 +83,7 @@ impl<'a> Renderer<'a> {
|
|||
.zip(variables)
|
||||
.zip(expressions)
|
||||
.map(|((symbol, variable), expr)| {
|
||||
let (error_type, _) = subs.var_to_error_type(*variable, Polarity::OF_VALUE);
|
||||
let error_type = subs.var_to_error_type(*variable, Polarity::OF_VALUE);
|
||||
self.render_lookup(*symbol, expr, error_type)
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue