Skip to content

Commit 7be8358

Browse files
neelanceRichard Musiol
authored and
Richard Musiol
committed
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 <[email protected]> Run-TryBot: Richard Musiol <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]>
1 parent f2ee58b commit 7be8358

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

misc/wasm/wasm_exec.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@
503503
}
504504

505505
async run(instance) {
506+
if (!(instance instanceof WebAssembly.Instance)) {
507+
throw new Error("Go.run: WebAssembly.Instance expected");
508+
}
506509
this._inst = instance;
507510
this.mem = new DataView(this._inst.exports.mem.buffer);
508511
this._values = [ // JS values that Go currently has references to, indexed by reference id

0 commit comments

Comments
 (0)