mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
record, tag, alias errors
- duplicate fields and tags are reported - circular aliases are reported
This commit is contained in:
parent
0372b34e86
commit
f6af66f342
13 changed files with 679 additions and 55 deletions
|
@ -73,6 +73,7 @@ struct Context {
|
|||
pub enum Unified {
|
||||
Success(Pool),
|
||||
Failure(Pool, ErrorType, ErrorType),
|
||||
BadType(Pool, roc_types::types::Problem),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -91,11 +92,18 @@ pub fn unify(subs: &mut Subs, var1: Variable, var2: Variable) -> Unified {
|
|||
if mismatches.is_empty() {
|
||||
Unified::Success(vars)
|
||||
} else {
|
||||
let type1 = subs.var_to_error_type(var1);
|
||||
let type2 = subs.var_to_error_type(var2);
|
||||
let (type1, mut problems) = subs.var_to_error_type(var1);
|
||||
let (type2, problems2) = subs.var_to_error_type(var2);
|
||||
|
||||
problems.extend(problems2);
|
||||
|
||||
subs.union(var1, var2, Content::Error.into());
|
||||
Unified::Failure(vars, type1, type2)
|
||||
|
||||
if !problems.is_empty() {
|
||||
Unified::BadType(vars, problems.remove(0))
|
||||
} else {
|
||||
Unified::Failure(vars, type1, type2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue