feat: fix some tests and add a failing one

This commit is contained in:
rvcas
2024-03-13 20:15:27 -04:00
parent 9127dcdd6e
commit e71470747f
8 changed files with 164 additions and 119 deletions

View File

@@ -1858,7 +1858,7 @@ fn forbid_expect_into_nested_opaque_in_record_without_typecasting() {
type Foo { foo: Thing }
fn bar(thing: Thing) {
fn bar(thing: Foo) {
expect Foo { foo: Thing { inner } } : Foo = thing
Void
}
@@ -1905,3 +1905,18 @@ fn forbid_expect_into_nested_opaque_in_list() {
Err((_, Error::ExpectOnOpaqueType { .. }))
))
}
#[test]
fn allow_expect_on_var_patterns_that_are_opaque() {
let source_code = r#"
opaque type Thing { inner: Int }
fn bar(a: Option<Thing>) {
expect Some(thing) = a
thing.inner
}
"#;
assert!(check(parse(source_code)).is_ok())
}