Merge pull request #4312 from roc-lang/i4309

Correctly destructure patterns that are assigned to a thunk'd value
This commit is contained in:
Folkert de Vries 2022-10-13 00:22:04 +02:00 committed by GitHub
commit da0a8f0b2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 16 deletions

View file

@ -1982,3 +1982,46 @@ fn str_with_prefix() {
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn destructure_pattern_assigned_from_thunk_opaque() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
MyCustomType := Str
myMsg = @MyCustomType "Hello"
main =
@MyCustomType msg = myMsg
msg
"#
),
RocStr::from("Hello"),
RocStr
);
}
#[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
fn destructure_pattern_assigned_from_thunk_tag() {
assert_evals_to!(
indoc!(
r#"
app "test" provides [main] to "./platform"
myMsg = A "hello " "world"
main =
A m1 m2 = myMsg
Str.concat m1 m2
"#
),
RocStr::from("hello world"),
RocStr
);
}