diff --git a/lib/codegen/codegen.ml b/lib/codegen/codegen.ml index f0f479a..ed09863 100644 --- a/lib/codegen/codegen.ml +++ b/lib/codegen/codegen.ml @@ -1288,7 +1288,7 @@ end = struct let dataptr = Llvm.build_struct_gep lltyp var 1 "data" builder in let data = gen_expr { param with alloca = Some dataptr } expr - |> bring_default_var + |> bring_default_var |> func_to_closure param in set_struct_field data dataptr diff --git a/test/functions.t/monomorph_variable.smu b/test/functions.t/monomorph_variable.smu index b8832d9..1f096fd 100644 --- a/test/functions.t/monomorph_variable.smu +++ b/test/functions.t/monomorph_variable.smu @@ -1,7 +1,6 @@ type ctor['a] = Ctor(array['a]) fun any() { - -- TODO using a concrete type here given another error in valgrind, but works fun cb(v) { println(fmt(v)) } @@ -11,3 +10,17 @@ fun any() { match any() { Ctor(f): f.[0](0) } + +type ctor2['a] = Ctor('a) + +fun any() { + fun cb(v) { + println(fmt(v)) + } + -- Moving a function directly into a variant didn't use to work + Ctor(cb) +} + +match any() { + Ctor(f): f(0) +} diff --git a/test/functions.t/run.t b/test/functions.t/run.t index 89b4ad7..c2fb7f7 100644 --- a/test/functions.t/run.t +++ b/test/functions.t/run.t @@ -2590,3 +2590,4 @@ Monomorphize functions as variables $ schmu monomorph_variable.smu $ valgrind -q --leak-check=yes --show-reachable=yes ./monomorph_variable 0 + 0