// issue-0010: Closure returning a protocol value generates invalid LLVM IR // // LLVM verification failed: Called function must be a pointer! // %icall = call addrspace(64) i64 %load56() // // A Closure() -> MyProtocol where MyProtocol is a protocol (not #inline) // fails at codegen. Calling the function directly works fine; only the // closure dispatch path is broken. #import "modules/std.sx"; MyProtocol :: protocol { get_value :: () -> s64; } MyImpl :: struct { value: s64; } impl MyProtocol for MyImpl { get_value :: (self: *MyImpl) -> s64 { self.value; } } make_thing :: () -> MyProtocol { MyImpl.{ value = 42 }; } main :: () -> void { // Direct call works: v := make_thing(); out("direct call works\n"); // Closure call crashes: c := closure(make_thing); result := c(); out("closure call works\n"); }