mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
exhaustiveness for record guards
This commit is contained in:
parent
0985037754
commit
82655556ab
4 changed files with 165 additions and 52 deletions
|
@ -72,9 +72,24 @@ fn simplify<'a>(pattern: &crate::expr::Pattern<'a>) -> Pattern {
|
|||
|
||||
Underscore => Anything,
|
||||
Identifier(_) => Anything,
|
||||
RecordDestructure { .. } => {
|
||||
// TODO we must check the guard conditions!
|
||||
Anything
|
||||
RecordDestructure(destructures, _) => {
|
||||
let union = Union {
|
||||
alternatives: vec![Ctor {
|
||||
name: TagName::Global("#Record".into()),
|
||||
arity: destructures.len(),
|
||||
}],
|
||||
};
|
||||
|
||||
let mut patterns = std::vec::Vec::with_capacity(destructures.len());
|
||||
|
||||
for destruct in destructures {
|
||||
match &destruct.guard {
|
||||
None => patterns.push(Anything),
|
||||
Some(guard) => patterns.push(simplify(guard)),
|
||||
}
|
||||
}
|
||||
|
||||
Ctor(union, TagName::Global("#Record".into()), patterns)
|
||||
}
|
||||
|
||||
Shadowed(_region, _ident) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue