Check exhaustiveness behavior on pattern guards.
This commit is contained in:
parent
4f7f39292d
commit
675b737898
|
@ -611,6 +611,30 @@ fn exhaustiveness_nested_list_and_tuples() {
|
|||
assert!(matches!(check(parse(source_code)), Ok(_)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exhaustiveness_guard() {
|
||||
let source_code = r#"
|
||||
fn foo() {
|
||||
when [(True, 42)] is {
|
||||
[(True, x), ..] if x == 42 -> Void
|
||||
[(False, x), ..] -> Void
|
||||
[] -> Void
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
assert!(matches!(
|
||||
check(parse(source_code)),
|
||||
Err((
|
||||
_,
|
||||
Error::NotExhaustivePatternMatch {
|
||||
unmatched,
|
||||
..
|
||||
}
|
||||
)) if unmatched[0] == "[(True, _), ..]"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn expect_sugar_correct_type() {
|
||||
let source_code = r#"
|
||||
|
|
Loading…
Reference in New Issue