mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Remove problem storage in Type::Erroneous
This commit is contained in:
parent
b984351514
commit
c9953129cb
9 changed files with 114 additions and 71 deletions
|
@ -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 {
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue