mirror of
https://github.com/roc-lang/roc.git
synced 2025-11-17 11:03:15 +00:00
Improve exhaustiveness checking heuristics for list patterns
This commit is contained in:
parent
a58d128d9e
commit
99a4e21618
1 changed files with 11 additions and 1 deletions
|
|
@ -1896,6 +1896,11 @@ fn open_tag_union(subs: &mut Subs, var: Variable) {
|
||||||
stack.extend(subs.get_subs_slice(fields.variables()));
|
stack.extend(subs.get_subs_slice(fields.variables()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Structure(Apply(Symbol::LIST_LIST, args)) => {
|
||||||
|
// Open up nested tag unions.
|
||||||
|
stack.extend(subs.get_subs_slice(args));
|
||||||
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
// Everything else is not a structural type that can be opened
|
// Everything else is not a structural type that can be opened
|
||||||
// (i.e. cannot be matched in a pattern-match)
|
// (i.e. cannot be matched in a pattern-match)
|
||||||
|
|
@ -1956,10 +1961,15 @@ fn close_pattern_matched_tag_unions(subs: &mut Subs, var: Variable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Structure(Record(fields, _)) => {
|
Structure(Record(fields, _)) => {
|
||||||
// Open up all nested tag unions.
|
// Close up all nested tag unions.
|
||||||
stack.extend(subs.get_subs_slice(fields.variables()));
|
stack.extend(subs.get_subs_slice(fields.variables()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Structure(Apply(Symbol::LIST_LIST, args)) => {
|
||||||
|
// Close up nested tag unions.
|
||||||
|
stack.extend(subs.get_subs_slice(args));
|
||||||
|
}
|
||||||
|
|
||||||
Alias(_, _, real_var, _) => {
|
Alias(_, _, real_var, _) => {
|
||||||
stack.push(real_var);
|
stack.push(real_var);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue