]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: fix string to type parameter conversions
authorRobert Griesemer <gri@golang.org>
Mon, 28 Feb 2022 02:13:23 +0000 (18:13 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 28 Feb 2022 21:50:54 +0000 (21:50 +0000)
commitf9285818b6890b896f43a38449e35744d97c817a
tree24a0768966397c45a5e19a125da39b98eaac071e
parenteb8198d2f67477517e7a735faa49dfd7c0fb3622
go/types, types2: fix string to type parameter conversions

Converting an untyped constant to a type parameter results
in a non-constant value; but the constant must still be
representable by all specific types of the type parameter.

Adjust the special handling for constant-to-type parameter
conversions to also include string-to-[]byte and []rune
conversions, which are handled separately for conversions
to types that are not type parameters because those are not
constant conversions in non-generic code.

Fixes #51386.

Change-Id: I15e5a0fd281efd15af387280cd3dee320a1ac5e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/388254
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/conversions.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51386.go2 [new file with mode: 0644]
src/go/types/conversions.go
src/go/types/testdata/fixedbugs/issue51386.go2 [new file with mode: 0644]