aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-09-05 18:56:26 -0400
committerCherry Mui <cherryyz@google.com>2024-09-11 20:01:21 +0000
commiteb975601a07ad25a47fdcb0cc6166ec695973d3e (patch)
tree662dce81535d3ad8467d03aac7203426b64d7f0b /test
parent69827b5c8ddf93be65bfc8b17d331bb3ff7b704c (diff)
downloadgo-eb975601a07ad25a47fdcb0cc6166ec695973d3e.tar.xz
cmd/compile: correct wasmexport result type checking
The function resultsToWasmFields was originally for only wasmimport. I adopted it for wasmexport as well, but forgot to update a few places that were wasmimport-specific. This leads to compiler panic if an invalid result type is passed, and also unsafe.Pointer not actually supported. This CL fixes it. Updates #65199. Change-Id: I9bbd7154b70422504994840ff541c39ee596ee8f Reviewed-on: https://go-review.googlesource.com/c/go/+/611315 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test')
-rw-r--r--test/wasmexport2.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/wasmexport2.go b/test/wasmexport2.go
index c7c0fa2ec8..e3b3bbed6e 100644
--- a/test/wasmexport2.go
+++ b/test/wasmexport2.go
@@ -24,6 +24,9 @@ func good2(MyInt32) {} // named type is ok
//go:wasmexport good3
func good3() int32 { return 0 } // one result is ok
+//go:wasmexport good4
+func good4() unsafe.Pointer { return nil } // one result is ok
+
//go:wasmexport bad1
func bad1(string) {} // ERROR "go:wasmexport: unsupported parameter type"
@@ -54,5 +57,11 @@ func bad7(*S) {} // ERROR "go:wasmexport: unsupported parameter type"
//go:wasmexport bad8
func bad8([4]int32) {} // ERROR "go:wasmexport: unsupported parameter type"
+//go:wasmexport bad9
+func bad9() bool { return false } // ERROR "go:wasmexport: unsupported result type"
+
+//go:wasmexport bad10
+func bad10() *byte { return nil } // ERROR "go:wasmexport: unsupported result type"
+
//go:wasmexport toomanyresults
func toomanyresults() (int32, int32) { return 0, 0 } // ERROR "go:wasmexport: too many return values"