aboutsummaryrefslogtreecommitdiff
path: root/test/escape_slice.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2022-09-12 13:01:57 -0700
committerMatthew Dempsky <mdempsky@google.com>2022-09-19 18:58:26 +0000
commitceffdc8545c3155b030de9e91d399dc34bd3c678 (patch)
treefb5079fbaef6a3178c80927ea89df3a2a7bc1c4b /test/escape_slice.go
parent29153be75763b7cbf9395d732f454336e3df0286 (diff)
downloadgo-ceffdc8545c3155b030de9e91d399dc34bd3c678.tar.gz
go-ceffdc8545c3155b030de9e91d399dc34bd3c678.zip
cmd/compile: implement slice-to-array conversions
The conversion T(x) is implemented as *(*T)(x). Accordingly, runtime panic messages for (*T)(x) are made more general. Fixes #46505. Change-Id: I76317c0878b6a5908299506d392eed50d7ef6523 Reviewed-on: https://go-review.googlesource.com/c/go/+/430415 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Jenny Rakoczy <jenny@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/escape_slice.go')
-rw-r--r--test/escape_slice.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/escape_slice.go b/test/escape_slice.go
index 055b60be41..7f94a755b9 100644
--- a/test/escape_slice.go
+++ b/test/escape_slice.go
@@ -105,6 +105,10 @@ func slice12(x []int) *[1]int { // ERROR "leaking param: x to result ~r0 level=0
return (*[1]int)(x)
}
+func slice13(x []*int) [1]*int { // ERROR "leaking param: x to result ~r0 level=1$"
+ return [1]*int(x)
+}
+
func envForDir(dir string) []string { // ERROR "dir does not escape"
env := os.Environ()
return mergeEnvLists([]string{"PWD=" + dir}, env) // ERROR ".PWD=. \+ dir escapes to heap" "\[\]string{...} does not escape"