From bcb563f4db2ce78be114689258c6a42201543bc5 Mon Sep 17 00:00:00 2001 From: Kunpei Sakai Date: Sun, 14 Jan 2018 04:05:21 +0900 Subject: [PATCH] cmd/compile: allow converting defined string types to []rune Fixes #23298 Change-Id: I107c6f3a80db83f063c0daf262c6e7f7492e4d4c Reviewed-on: https://go-review.googlesource.com/87695 Run-TryBot: Kunpei Sakai Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/walk.go | 2 +- test/fixedbugs/issue23298.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue23298.go diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go index f48513dc73..872b20925e 100644 --- a/src/cmd/compile/internal/gc/walk.go +++ b/src/cmd/compile/internal/gc/walk.go @@ -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 index 0000000000..be00a8ec67 --- /dev/null +++ b/test/fixedbugs/issue23298.go @@ -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) +)