Skip to content

Commit be39e9c

Browse files
committed
compiler: improve panic message when a runtime call is unavailable
This should not happen under normal circumstances. It can still happen when there is a mismatch between TinyGo version and the associated runtime, or while developing the compiler package.
1 parent 8cf55d0 commit be39e9c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/calls.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ const (
3636
// createRuntimeCallCommon creates a runtime call. Use createRuntimeCall or
3737
// createRuntimeInvoke instead.
3838
func (b *builder) createRuntimeCallCommon(fnName string, args []llvm.Value, name string, isInvoke bool) llvm.Value {
39-
fn := b.program.ImportedPackage("runtime").Members[fnName].(*ssa.Function)
39+
member := b.program.ImportedPackage("runtime").Members[fnName]
40+
if member == nil {
41+
panic("unknown runtime call: " + fnName)
42+
}
43+
fn := member.(*ssa.Function)
4044
fnType, llvmFn := b.getFunction(fn)
4145
if llvmFn.IsNil() {
4246
panic("trying to call non-existent function: " + fn.RelString(nil))

0 commit comments

Comments
 (0)