aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorRichard Musiol <mail@richard-musiol.de>2020-10-29 00:07:04 +0100
committerRichard Musiol <neelance@gmail.com>2020-11-02 13:02:40 +0000
commit7be8358f70ff858f28b9aefe11986da25f1762bc (patch)
tree9951b3b20875f33e0ea718dea118f628392623c9 /misc
parentf2ee58b6bb3d8312dad2ed7826c1a0e67aea8483 (diff)
downloadgo-7be8358f70ff858f28b9aefe11986da25f1762bc.tar.gz
go-7be8358f70ff858f28b9aefe11986da25f1762bc.zip
misc/wasm: check type of argument to Go.run
This results in a nicer error message if the argument to Go.run is omitted or of the wrong type. Fixes #37000 Change-Id: I7f36d007f41a79b2cea1cebf5cce127786341202 Reviewed-on: https://go-review.googlesource.com/c/go/+/266117 Trust: Richard Musiol <neelance@gmail.com> Run-TryBot: Richard Musiol <neelance@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'misc')
-rw-r--r--misc/wasm/wasm_exec.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/misc/wasm/wasm_exec.js b/misc/wasm/wasm_exec.js
index 3ea03c45b7..82041e6bb9 100644
--- a/misc/wasm/wasm_exec.js
+++ b/misc/wasm/wasm_exec.js
@@ -503,6 +503,9 @@
}
async run(instance) {
+ if (!(instance instanceof WebAssembly.Instance)) {
+ throw new Error("Go.run: WebAssembly.Instance expected");
+ }
this._inst = instance;
this.mem = new DataView(this._inst.exports.mem.buffer);
this._values = [ // JS values that Go currently has references to, indexed by reference id