mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Newtype destructures test for record that decay into their only arg
This commit is contained in:
parent
929a00e73d
commit
f3722659fc
2 changed files with 26 additions and 2 deletions
|
@ -985,9 +985,13 @@ fn needs_tests(pattern: &Pattern) -> bool {
|
||||||
// read the appropriate argument in the struct when constructing the decision tree.
|
// read the appropriate argument in the struct when constructing the decision tree.
|
||||||
arguments.len() != 1
|
arguments.len() != 1
|
||||||
}
|
}
|
||||||
|
RecordDestructure(arguments, _) => {
|
||||||
|
// Same logic as for newtype destructures - records with one argument decay into their
|
||||||
|
// argument.
|
||||||
|
arguments.len() != 1
|
||||||
|
}
|
||||||
|
|
||||||
RecordDestructure(_, _)
|
AppliedTag { .. }
|
||||||
| AppliedTag { .. }
|
|
||||||
| OpaqueUnwrap { .. }
|
| OpaqueUnwrap { .. }
|
||||||
| BitLiteral { .. }
|
| BitLiteral { .. }
|
||||||
| EnumLiteral { .. }
|
| EnumLiteral { .. }
|
||||||
|
|
|
@ -1825,3 +1825,23 @@ fn issue_3560_nested_tag_constructor_is_newtype() {
|
||||||
(u8, u8)
|
(u8, u8)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm"))]
|
||||||
|
fn issue_3560_nested_tag_constructor_is_record_newtype() {
|
||||||
|
assert_evals_to!(
|
||||||
|
indoc!(
|
||||||
|
r#"
|
||||||
|
f : _ -> u8
|
||||||
|
f = \t ->
|
||||||
|
when t is
|
||||||
|
{wrapper: (Payload it)} -> it
|
||||||
|
{wrapper: (AlternatePayload it)} -> it
|
||||||
|
|
||||||
|
{a: f {wrapper: (Payload 15u8)}, b: f {wrapper: (AlternatePayload 31u8)}}
|
||||||
|
"#
|
||||||
|
),
|
||||||
|
(15, 31),
|
||||||
|
(u8, u8)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue