diff --git a/crates/compiler/can/tests/test_can.rs b/crates/compiler/can/tests/test_can.rs index 4945c0ccf36..2afe3eff297 100644 --- a/crates/compiler/can/tests/test_can.rs +++ b/crates/compiler/can/tests/test_can.rs @@ -1231,54 +1231,6 @@ mod test_can { assert_eq!(problems, Vec::new()); } - #[test] - fn optional_field_with_binary_op() { - let src = indoc!( - r#" - { bar ? 1 + 1 } = {} - bar - "# - ); - let arena = Bump::new(); - let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src); - - assert_eq!(problems, Vec::new()); - } - - #[test] - fn nested_optional_field_with_binary_op() { - let src = indoc!( - r#" - when { x: ([{}], "foo") } is - { x: ([{ bar ? 1 + 1 }], _) } -> bar - "# - ); - let arena = Bump::new(); - let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src); - - assert_eq!(problems, Vec::new()); - } - - #[test] - fn multiline_record_pattern() { - let src = indoc!( - r#" - x = { a: 1, b: 2, c: 3 } - { - a, - b, - c, - } = x - - a + b + c - "# - ); - let arena = Bump::new(); - let CanExprOut { problems, .. } = can_expr_with(&arena, test_home(), src); - - assert_eq!(problems, Vec::new()); - } - #[test] fn issue_2534() { let src = indoc!( diff --git a/crates/compiler/test_mono/generated/multiline_record_pattern.txt b/crates/compiler/test_mono/generated/multiline_record_pattern.txt new file mode 100644 index 00000000000..2e73bc54863 --- /dev/null +++ b/crates/compiler/test_mono/generated/multiline_record_pattern.txt @@ -0,0 +1,15 @@ +procedure Num.19 (#Attr.2, #Attr.3): + let Num.292 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.292; + +procedure Test.0 (): + let Test.7 : I64 = 1i64; + let Test.8 : I64 = 2i64; + let Test.9 : I64 = 3i64; + let Test.1 : {I64, I64, I64} = Struct {Test.7, Test.8, Test.9}; + let Test.2 : I64 = StructAtIndex 0 Test.1; + let Test.3 : I64 = StructAtIndex 1 Test.1; + let Test.4 : I64 = StructAtIndex 2 Test.1; + let Test.6 : I64 = CallByName Num.19 Test.2 Test.3; + let Test.5 : I64 = CallByName Num.19 Test.6 Test.4; + ret Test.5; diff --git a/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt b/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt new file mode 100644 index 00000000000..404f08f3d88 --- /dev/null +++ b/crates/compiler/test_mono/generated/nested_optional_field_with_binary_op.txt @@ -0,0 +1,23 @@ +procedure Num.19 (#Attr.2, #Attr.3): + let Num.291 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.291; + +procedure Test.0 (): + let Test.17 : {} = Struct {}; + let Test.15 : List {} = Array [Test.17]; + let Test.16 : Str = "foo"; + let Test.14 : {List {}, Str} = Struct {Test.15, Test.16}; + let Test.10 : List {} = StructAtIndex 0 Test.14; + dec Test.16; + let Test.11 : U64 = lowlevel ListLen Test.10; + dec Test.10; + let Test.12 : U64 = 1i64; + let Test.13 : Int1 = lowlevel Eq Test.11 Test.12; + if Test.13 then + let Test.5 : I64 = 1i64; + let Test.6 : I64 = 1i64; + let Test.2 : I64 = CallByName Num.19 Test.5 Test.6; + ret Test.2; + else + let Test.7 : I64 = 0i64; + ret Test.7; diff --git a/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt b/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt new file mode 100644 index 00000000000..d0bfce4f16b --- /dev/null +++ b/crates/compiler/test_mono/generated/optional_field_with_binary_op.txt @@ -0,0 +1,10 @@ +procedure Num.19 (#Attr.2, #Attr.3): + let Num.291 : I64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.291; + +procedure Test.0 (): + let Test.5 : {} = Struct {}; + let Test.3 : I64 = 1i64; + let Test.4 : I64 = 1i64; + let Test.1 : I64 = CallByName Num.19 Test.3 Test.4; + ret Test.1; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index ae2a28ec5b0..0f56a1f2373 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -893,6 +893,37 @@ fn optional_when() { "# } +#[mono_test] +fn optional_field_with_binary_op() { + r#" + { bar ? 1 + 1 } = {} + bar + "# +} + +#[mono_test] +fn nested_optional_field_with_binary_op() { + r#" + when { x: ([{}], "foo") } is + { x: ([{ bar ? 1 + 1 }], _) } -> bar + _ -> 0 + "# +} + +#[mono_test] +fn multiline_record_pattern() { + r#" + x = { a: 1, b: 2, c: 3 } + { + a, + b, + c, + } = x + + a + b + c + "# +} + #[mono_test] fn nested_pattern_match() { r#"