diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2022-09-12 13:01:57 -0700 |
|---|---|---|
| committer | Matthew Dempsky <mdempsky@google.com> | 2022-09-19 18:58:26 +0000 |
| commit | ceffdc8545c3155b030de9e91d399dc34bd3c678 (patch) | |
| tree | fb5079fbaef6a3178c80927ea89df3a2a7bc1c4b /src/runtime | |
| parent | 29153be75763b7cbf9395d732f454336e3df0286 (diff) | |
| download | go-ceffdc8545c3155b030de9e91d399dc34bd3c678.tar.xz | |
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 'src/runtime')
| -rw-r--r-- | src/runtime/error.go | 2 | ||||
| -rw-r--r-- | src/runtime/panic.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/error.go b/src/runtime/error.go index b11473c634..a211fbf515 100644 --- a/src/runtime/error.go +++ b/src/runtime/error.go @@ -151,7 +151,7 @@ var boundsErrorFmts = [...]string{ boundsSlice3Acap: "slice bounds out of range [::%x] with capacity %y", boundsSlice3B: "slice bounds out of range [:%x:%y]", boundsSlice3C: "slice bounds out of range [%x:%y:]", - boundsConvert: "cannot convert slice with length %y to pointer to array with length %x", + boundsConvert: "cannot convert slice with length %y to array or pointer to array with length %x", } // boundsNegErrorFmts are overriding formats if x is negative. In this case there's no need to report y. diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 92ef96882f..26618db7ce 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -197,9 +197,9 @@ func goPanicSlice3CU(x uint, y int) { panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3C}) } -// failures in the conversion (*[x]T)s, 0 <= x <= y, x == cap(s) +// failures in the conversion ([x]T)(s) or (*[x]T)(s), 0 <= x <= y, y == len(s) func goPanicSliceConvert(x int, y int) { - panicCheck1(getcallerpc(), "slice length too short to convert to pointer to array") + panicCheck1(getcallerpc(), "slice length too short to convert to array or pointer to array") panic(boundsError{x: int64(x), signed: true, y: y, code: boundsConvert}) } |
