Skip to content

Commit 72e0b64

Browse files
committed
compiler/natives/src/runtime: Keep throw accessible for Go code to use.
In Go 1.9, runtime.panicwrap uses throw. So it needs to be accessible from Go code now. Fixes: ../src/runtime/error.go:134:3: undeclared name: throw ../src/runtime/error.go:144:3: undeclared name: throw ../src/runtime/error.go:148:3: undeclared name: throw ../src/runtime/error.go:153:3: undeclared name: throw ../src/runtime/error.go:156:3: undeclared name: throw
1 parent 15a2eea commit 72e0b64

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

compiler/natives/src/runtime/runtime.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ func init() {
2727
jsPkg := js.Global.Get("$packages").Get("github.com/gopherjs/gopherjs/js")
2828
js.Global.Set("$jsObjectPtr", jsPkg.Get("Object").Get("ptr"))
2929
js.Global.Set("$jsErrorPtr", jsPkg.Get("Error").Get("ptr"))
30-
js.Global.Set("$throwRuntimeError", js.InternalObject(func(msg string) {
31-
panic(errorString(msg))
32-
}))
30+
js.Global.Set("$throwRuntimeError", js.InternalObject(throw))
3331
// avoid dead code elimination
3432
var e error
3533
e = &TypeAssertionError{}
@@ -199,3 +197,7 @@ func efaceOf(ep *interface{}) *eface {
199197
}
200198

201199
func KeepAlive(interface{}) {}
200+
201+
func throw(s string) {
202+
panic(errorString(s))
203+
}

0 commit comments

Comments
 (0)