Remove problem storage in Type::Erroneous

This commit is contained in:
Ayaz Hafiz 2022-11-08 13:19:43 -06:00
parent b984351514
commit c9953129cb
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
9 changed files with 114 additions and 71 deletions

View file

@ -1037,6 +1037,54 @@ pub fn can_problem<'b>(
title = "MULTIPLE LIST REST PATTERNS".to_string();
severity = Severity::RuntimeError;
}
Problem::BadType(type_problem) => {
use roc_types::types::Problem::*;
match type_problem {
BadTypeArguments {
symbol,
region,
type_got,
alias_needs,
alias_kind,
} => {
let needed_arguments = if alias_needs == 1 {
alloc.reflow("1 type argument")
} else {
alloc
.text(alias_needs.to_string())
.append(alloc.reflow(" type arguments"))
};
let found_arguments = alloc.text(type_got.to_string());
doc = alloc.stack([
alloc.concat([
alloc.reflow("The "),
alloc.symbol_unqualified(symbol),
alloc.reflow(" "),
alloc.reflow(alias_kind.as_str()),
alloc.reflow(" expects "),
needed_arguments,
alloc.reflow(", but it got "),
found_arguments,
alloc.reflow(" instead:"),
]),
alloc.region(lines.convert_region(region)),
alloc.reflow("Are there missing parentheses?"),
]);
title = if type_got > alias_needs {
"TOO MANY TYPE ARGUMENTS".to_string()
} else {
"TOO FEW TYPE ARGUMENTS".to_string()
};
severity = Severity::RuntimeError;
}
other => panic!("unhandled bad type: {:?}", other),
}
}
};
Report {

View file

@ -126,12 +126,6 @@ pub fn type_problem<'b>(
report(title, doc, filename)
}
SolvedTypeError => None, // Don't re-report cascading errors - see https://github.com/roc-lang/roc/pull/1711
// We'll also report these as a canonicalization problem, no need to re-report them.
CyclicAlias(..) => None,
UnrecognizedIdent(..) => None,
other => panic!("unhandled bad type: {:?}", other),
}
}