]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix conv of slice of user-define byte type to string
authorDan Scales <danscales@google.com>
Thu, 6 Jan 2022 20:39:37 +0000 (12:39 -0800)
committerDan Scales <danscales@google.com>
Fri, 7 Jan 2022 18:40:16 +0000 (18:40 +0000)
commitf1596d76f488e4d82d217418df4191f34b71d117
tree1771b8b19ecd2dd2588330fe92c88600045dc631
parentade5488d75fefc4afd72f2f6090f4c823c93d083
cmd/compile: fix conv of slice of user-define byte type to string

types2 allows the conversion of a slice of a user-defined byte type B
(not builtin uint8 or byte) to string. But runtime.slicebytetostring
requires a []byte argument, so add in a CONVNOP from []B to []byte if
needed. Same for the conversion of a slice of user-defined rune types to
string.

I made the same change in the transformations of the old typechecker, so
as to keep tcConv() and transformConv() in sync. That fixes the bug for
-G=0 mode as well.

Fixes #23536

Change-Id: Ic79364427f27489187f3f8015bdfbf0769a70d69
Reviewed-on: https://go-review.googlesource.com/c/go/+/376056
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/noder/transform.go
src/cmd/compile/internal/typecheck/expr.go
test/fixedbugs/issue23536.go [new file with mode: 0644]
test/typeparam/issue23536.go [new file with mode: 0644]