aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2023-12-01 00:16:24 +0700
committerGopher Robot <gobot@golang.org>2023-12-01 17:20:08 +0000
commitfbfe62bc802d27539a858afd66ae335ff94b1d25 (patch)
tree50fba20f0a404a763f676459c4e14ba6a1b9452e /test
parent446a5dcf5a3230ce9832682d8f521071d8a34a2b (diff)
downloadgo-fbfe62bc802d27539a858afd66ae335ff94b1d25.tar.gz
go-fbfe62bc802d27539a858afd66ae335ff94b1d25.zip
cmd/compile: fix typecheck range over rune literal
With range over int, the rune literal in range expression will be left as untyped rune, but idealType is not handling this case, causing ICE. Fixing this by setting the concrete type for untyped rune expresison. Fixes #64471 Change-Id: I07a151c54ea1d9e1b92e4d96cdfb6e73dca13862 Reviewed-on: https://go-review.googlesource.com/c/go/+/546296 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'test')
-rw-r--r--test/range3.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/range3.go b/test/range3.go
index 4f770a2b70..f58a398f94 100644
--- a/test/range3.go
+++ b/test/range3.go
@@ -74,9 +74,17 @@ func testint4() {
}
}
+// Issue #64471.
+func testint5() {
+ for i := range 'a' {
+ var _ *rune = &i // ensure i has type rune
+ }
+}
+
func main() {
testint1()
testint2()
testint3()
testint4()
+ testint5()
}