]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: allow converting defined string types to []rune
authorKunpei Sakai <namusyaka@gmail.com>
Sat, 13 Jan 2018 19:05:21 +0000 (04:05 +0900)
committerMatthew Dempsky <mdempsky@google.com>
Thu, 15 Feb 2018 00:25:21 +0000 (00:25 +0000)
Fixes #23298

Change-Id: I107c6f3a80db83f063c0daf262c6e7f7492e4d4c
Reviewed-on: https://go-review.googlesource.com/87695
Run-TryBot: Kunpei Sakai <namusyaka@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/walk.go
test/fixedbugs/issue23298.go [new file with mode: 0644]

index f48513dc73d1efef0c0e58f61a0d0d4d96773239..872b20925e27189d5a50d714ee39ed33f2d11844 100644 (file)
@@ -1665,7 +1665,7 @@ opswitch:
                        a = nod(OADDR, temp(t), nil)
                }
 
-               n = mkcall("stringtoslicerune", n.Type, init, a, n.Left)
+               n = mkcall("stringtoslicerune", n.Type, init, a, conv(n.Left, types.Types[TSTRING]))
 
                // ifaceeq(i1 any-1, i2 any-2) (ret bool);
        case OCMPIFACE:
diff --git a/test/fixedbugs/issue23298.go b/test/fixedbugs/issue23298.go
new file mode 100644 (file)
index 0000000..be00a8e
--- /dev/null
@@ -0,0 +1,14 @@
+// compile
+
+// Copyright 2018 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.
+
+package p
+
+type T string
+
+var (
+       t = T("T")
+       r = []rune(t)
+)