mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Fix bug in closing heuristic
This commit is contained in:
parent
7b9ce492c3
commit
bb1f4cd5e8
1 changed files with 17 additions and 2 deletions
|
@ -1866,6 +1866,12 @@ fn open_tag_union(subs: &mut Subs, var: Variable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Optimistically closes the positive type of a value matched in a `when` statement, to produce
|
||||||
|
/// better exhaustiveness error messages.
|
||||||
|
///
|
||||||
|
/// This should only be applied if it's already known that a `when` expression is not exhaustive.
|
||||||
|
///
|
||||||
|
/// See [Constraint::Exhaustive].
|
||||||
fn close_pattern_matched_tag_unions(subs: &mut Subs, var: Variable) {
|
fn close_pattern_matched_tag_unions(subs: &mut Subs, var: Variable) {
|
||||||
let mut stack = vec![var];
|
let mut stack = vec![var];
|
||||||
while let Some(var) = stack.pop() {
|
while let Some(var) = stack.pop() {
|
||||||
|
@ -1884,11 +1890,20 @@ fn close_pattern_matched_tag_unions(subs: &mut Subs, var: Variable) {
|
||||||
subs.set_content_unchecked(ext, Structure(FlatType::EmptyTagUnion));
|
subs.set_content_unchecked(ext, Structure(FlatType::EmptyTagUnion));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
RigidVar(..) | RigidAbleVar(..) => {
|
||||||
|
// Don't touch rigids, they tell us more information than the heuristic
|
||||||
|
// of closing tag unions does for better exhaustiveness checking does.
|
||||||
|
break;
|
||||||
|
}
|
||||||
Structure(FlatType::TagUnion(_, deep_ext))
|
Structure(FlatType::TagUnion(_, deep_ext))
|
||||||
| Structure(FlatType::RecursiveTagUnion(_, _, deep_ext)) => {
|
| Structure(FlatType::RecursiveTagUnion(_, _, deep_ext))
|
||||||
|
| Structure(FlatType::FunctionOrTagUnion(_, _, deep_ext)) => {
|
||||||
ext = *deep_ext;
|
ext = *deep_ext;
|
||||||
}
|
}
|
||||||
_ => internal_error!("not a tag union"),
|
other => internal_error!(
|
||||||
|
"not a tag union: {:?}",
|
||||||
|
roc_types::subs::SubsFmtContent(other, subs)
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue