diff --git a/.release-notes/4479.md b/.release-notes/4479.md new file mode 100644 index 0000000000..7cf8e6483e --- /dev/null +++ b/.release-notes/4479.md @@ -0,0 +1,7 @@ +## Fix esoteric bug with serializing bare lambdas + +Almost no one uses bare lambdas. And even fewer folks end up passing them through the Pony serialization code. So, of course, Red Davies did just that. And of course, he found a bug. + +When we switched to LLVM 15 in 0.54.1, we had to account for a rather large change with how LLVM handles pointer and types. In the process of doing that update, a mistake was made and serializing of bare lambdas was broken. + +We've made the fix and introduced a regression test. Enjoy your fix Red! diff --git a/src/libponyc/codegen/genserialise.c b/src/libponyc/codegen/genserialise.c index 75fd99d320..5f61be8983 100644 --- a/src/libponyc/codegen/genserialise.c +++ b/src/libponyc/codegen/genserialise.c @@ -290,7 +290,7 @@ static void deserialise_bare_interface(compile_t* c, LLVMValueRef ptr) LLVMValueRef desc = LLVMBuildInBoundsGEP2(c->builder, LLVMArrayType(c->ptr, 0), c->desc_table, args, 2, ""); - desc = LLVMBuildLoad2(c->builder, c->descriptor_type, desc, ""); + desc = LLVMBuildLoad2(c->builder, c->ptr, desc, ""); LLVMValueRef func = gendesc_instance(c, desc); LLVMBuildStore(c->builder, func, ptr); } diff --git a/test/full-program-tests/regression-4479/main.pony b/test/full-program-tests/regression-4479/main.pony new file mode 100644 index 0000000000..9690aafd54 --- /dev/null +++ b/test/full-program-tests/regression-4479/main.pony @@ -0,0 +1,9 @@ +actor Main + new create(env: Env) => None + let cb: Callbacks = Callbacks + +class Callbacks + var cbi: @{(): None} + + new create() => + cbi = @{() => None}