exhaustiveness for record guards

This commit is contained in:
Folkert 2020-03-19 22:34:08 +01:00
parent 0985037754
commit 82655556ab
4 changed files with 165 additions and 52 deletions

View file

@ -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) => {