From e9d549d2118bac33b384db34609c8ce1555cf4b7 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Wed, 4 Nov 2020 23:39:26 +0100 Subject: [PATCH] compiler: fix incorrect "exported function" panic Because the parentHandle parameter wasn't always set to the right value, the coroutine lowering pass would sometimes panic with "trying to make exported function async" even though there was no exported function involved. Therefore, it should unconditionally be set to avoid this. The parent function doesn't always have the parentHandle function parameter set because it can only be set after defining a function, not when it is only declared. --- compiler/interface.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/compiler/interface.go b/compiler/interface.go index fa08c5b0..030c6757 100644 --- a/compiler/interface.go +++ b/compiler/interface.go @@ -465,9 +465,7 @@ func (c *compilerContext) getInterfaceInvokeWrapper(f *ir.Function) llvm.Value { paramTypes := append([]llvm.Type{c.i8ptrType}, fnType.ParamTypes()[len(expandedReceiverType):]...) wrapFnType := llvm.FunctionType(fnType.ReturnType(), paramTypes, false) wrapper = llvm.AddFunction(c.mod, wrapperName, wrapFnType) - if f.LLVMFn.LastParam().Name() == "parentHandle" { - wrapper.LastParam().SetName("parentHandle") - } + wrapper.LastParam().SetName("parentHandle") wrapper.SetLinkage(llvm.InternalLinkage) wrapper.SetUnnamedAddr(true)