]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/gc: type of str[i] is byte, not uint8
authorRuss Cox <rsc@golang.org>
Tue, 19 May 2015 18:00:27 +0000 (14:00 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 19 May 2015 19:20:25 +0000 (19:20 +0000)
Fixes #8745.

Change-Id: Id0641e3c0f259812b41ed871e83c68740feb2b19
Reviewed-on: https://go-review.googlesource.com/10261
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/internal/gc/typecheck.go
test/fixedbugs/issue8745.go [new file with mode: 0644]

index 8af9f084e2368f5626610d98eab11e727d560563..0395ec5f5b66ce0ea2ed93ef0f6ae730848e6958 100644 (file)
@@ -1027,7 +1027,7 @@ OpSwitch:
                case TSTRING, TARRAY:
                        indexlit(&n.Right)
                        if t.Etype == TSTRING {
-                               n.Type = Types[TUINT8]
+                               n.Type = bytetype
                        } else {
                                n.Type = t.Type
                        }
diff --git a/test/fixedbugs/issue8745.go b/test/fixedbugs/issue8745.go
new file mode 100644 (file)
index 0000000..f3a70af
--- /dev/null
@@ -0,0 +1,13 @@
+// errorcheck
+
+// Copyright 2015 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.
+
+// Check that the error says s[2] is a byte, not a uint8.
+
+package p
+
+func f(s string) {
+       var _ float64 = s[2] // ERROR "cannot use.*type byte.*as type float64"
+}