diff options
author | Ayke van Laethem <[email protected]> | 2023-07-07 15:21:23 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-08-04 11:59:11 +0200 |
commit | 62294feb5609e6e39ec09e21469fe166dfbc55e1 (patch) | |
tree | fa2529ec23f82e691274fa57d708d3497139cc4e | |
parent | f1e25a18d2584cda1d7b2d478e17a4358ee7daf0 (diff) | |
download | tinygo-62294feb5609e6e39ec09e21469fe166dfbc55e1.tar.gz tinygo-62294feb5609e6e39ec09e21469fe166dfbc55e1.zip |
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.
-rw-r--r-- | compiler/calls.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/calls.go b/compiler/calls.go index 65a69fea3..a110addcf 100644 --- a/compiler/calls.go +++ b/compiler/calls.go @@ -36,7 +36,11 @@ const ( // createRuntimeCallCommon creates a runtime call. Use createRuntimeCall or // createRuntimeInvoke instead. func (b *builder) createRuntimeCallCommon(fnName string, args []llvm.Value, name string, isInvoke bool) llvm.Value { - fn := b.program.ImportedPackage("runtime").Members[fnName].(*ssa.Function) + member := b.program.ImportedPackage("runtime").Members[fnName] + if member == nil { + panic("unknown runtime call: " + fnName) + } + fn := member.(*ssa.Function) fnType, llvmFn := b.getFunction(fn) if llvmFn.IsNil() { panic("trying to call non-existent function: " + fn.RelString(nil)) |