diff --git a/crates/compiler/test_mono/generated/issue_4733.txt b/crates/compiler/test_mono/generated/issue_4733.txt new file mode 100644 index 0000000000..438b39eb97 --- /dev/null +++ b/crates/compiler/test_mono/generated/issue_4733.txt @@ -0,0 +1,49 @@ +procedure Bool.11 (#Attr.2, #Attr.3): + let Bool.23 : Int1 = lowlevel Eq #Attr.2 #Attr.3; + ret Bool.23; + +procedure Bool.2 (): + let Bool.24 : Int1 = true; + ret Bool.24; + +procedure Num.19 (#Attr.2, #Attr.3): + let Num.256 : U64 = lowlevel NumAdd #Attr.2 #Attr.3; + ret Num.256; + +procedure Num.21 (#Attr.2, #Attr.3): + let Num.257 : U64 = lowlevel NumMul #Attr.2 #Attr.3; + ret Num.257; + +procedure Test.0 (Test.8): + let Test.23 : Int1 = CallByName Bool.2; + if Test.23 then + let Test.24 : {} = Struct {}; + ret Test.24; + else + let Test.22 : {} = Struct {}; + ret Test.22; + +procedure Test.5 (Test.6, Test.2): + joinpoint Test.19 Test.18: + ret Test.18; + in + switch Test.2: + case 0: + let Test.20 : U64 = CallByName Num.19 Test.6 Test.6; + jump Test.19 Test.20; + + default: + let Test.21 : U64 = CallByName Num.21 Test.6 Test.6; + jump Test.19 Test.21; + + +procedure Test.7 (): + let Test.13 : U64 = 3i64; + let Test.15 : {} = Struct {}; + let Test.14 : Int1 = CallByName Test.0 Test.15; + let Test.11 : U64 = CallByName Test.5 Test.13 Test.14; + let Test.12 : U64 = 9i64; + let Test.10 : Int1 = CallByName Bool.11 Test.11 Test.12; + expect Test.10; + let Test.9 : {} = Struct {}; + ret Test.9; diff --git a/crates/compiler/test_mono/src/tests.rs b/crates/compiler/test_mono/src/tests.rs index 9791c9a139..a0ee692d8e 100644 --- a/crates/compiler/test_mono/src/tests.rs +++ b/crates/compiler/test_mono/src/tests.rs @@ -2173,3 +2173,22 @@ fn issue_4749() { "### ) } + +#[mono_test(mode = "test", no_check)] +fn issue_4733() { + indoc!( + r###" + interface Test exposes [] imports [] + + fn = \{} -> + instr : [ Op (U64, U64 -> U64) ] + instr = if Bool.true then (Op Num.mul) else (Op Num.add) + + Op op = instr + + \a -> op a a + + expect ((fn {}) 3) == 9 + "### + ) +}