mirror of
https://github.com/golang/go
synced 2024-11-18 03:34:42 -07:00
f1596d76f4
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>
23 lines
428 B
Go
23 lines
428 B
Go
// run
|
|
|
|
// Copyright 2022 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Test case where a slice of a user-defined byte type (not uint8 or byte) is
|
|
// converted to a string. Same for slice of runes.
|
|
|
|
package main
|
|
|
|
type MyByte byte
|
|
|
|
type MyRune rune
|
|
|
|
func main() {
|
|
var y []MyByte
|
|
_ = string(y)
|
|
|
|
var z []MyRune
|
|
_ = string(z)
|
|
}
|