Only expand ErrorType::Range's type range when range unification fails

This commit is contained in:
ayazhafiz 2022-02-06 14:55:22 -05:00
parent aaac22f6c2
commit 0d241f3c3c
6 changed files with 215 additions and 98 deletions

View file

@ -72,7 +72,6 @@ pub enum TypeError {
CircularType(Region, Symbol, ErrorType),
BadType(roc_types::types::Problem),
UnexposedLookup(Symbol),
NotInRange(Region, ErrorType, Expected<Vec<ErrorType>>),
}
#[derive(Clone, Debug, Default)]
@ -232,17 +231,6 @@ fn solve(
problems.push(TypeError::BadType(problem));
state
}
NotInRange(vars, typ, range) => {
introduce(subs, rank, pools, &vars);
problems.push(TypeError::NotInRange(
*region,
typ,
expectation.clone().replace(range),
));
state
}
}
@ -266,7 +254,7 @@ fn solve(
state
}
BadType(vars, _) | NotInRange(vars, _, _) => {
BadType(vars, _) => {
introduce(subs, rank, pools, &vars);
// ERROR NOT REPORTED
@ -333,17 +321,6 @@ fn solve(
problems.push(TypeError::BadType(problem));
state
}
NotInRange(vars, typ, range) => {
introduce(subs, rank, pools, &vars);
problems.push(TypeError::NotInRange(
*region,
typ,
expectation.clone().replace(range),
));
state
}
}
@ -414,18 +391,6 @@ fn solve(
problems.push(TypeError::BadType(problem));
state
}
NotInRange(vars, typ, range) => {
introduce(subs, rank, pools, &vars);
problems.push(TypeError::NotInRange(
*region,
typ,
// TODO expectation.clone().replace(range),
Expected::NoExpectation(range),
));
state
}
}
@ -720,17 +685,6 @@ fn solve(
problems.push(TypeError::BadType(problem));
state
}
NotInRange(vars, typ, range) => {
introduce(subs, rank, pools, &vars);
problems.push(TypeError::NotInRange(
Region::zero(),
typ,
Expected::NoExpectation(range),
));
state
}
}