mirror of https://github.com/golang/go.git
cmd/compile/internal/types2: better position for "3-index slice of string" error
As a result, slightly narrow position tolerance for tests. Change-Id: I543dc2b7b9a7940b0684067d1961165b2b4812bb Reviewed-on: https://go-review.googlesource.com/c/go/+/363670 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
0a54a6826e
commit
42fa03a88c
|
|
@ -277,7 +277,7 @@ func TestManual(t *testing.T) {
|
|||
|
||||
// TODO(gri) go/types has extra TestLongConstants and TestIndexRepresentability tests
|
||||
|
||||
func TestCheck(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/check", 75, false) } // TODO(gri) narrow column tolerance
|
||||
func TestCheck(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/check", 55, false) } // TODO(gri) narrow column tolerance
|
||||
func TestSpec(t *testing.T) { DefPredeclaredTestFuncs(); testDirFiles(t, "testdata/spec", 0, false) }
|
||||
func TestExamples(t *testing.T) { testDirFiles(t, "testdata/examples", 0, false) }
|
||||
func TestFixedbugs(t *testing.T) { testDirFiles(t, "testdata/fixedbugs", 0, false) }
|
||||
|
|
|
|||
|
|
@ -222,7 +222,11 @@ func (check *Checker) sliceExpr(x *operand, e *syntax.SliceExpr) {
|
|||
case *Basic:
|
||||
if isString(u) {
|
||||
if e.Full {
|
||||
check.error(x, invalidOp+"3-index slice of string")
|
||||
at := e.Index[2]
|
||||
if at == nil {
|
||||
at = e // e.Index[2] should be present but be careful
|
||||
}
|
||||
check.error(at, invalidOp+"3-index slice of string")
|
||||
x.mode = invalid
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ func indexes() {
|
|||
_ = t[- /* ERROR "negative" */ 1]
|
||||
_ = t[- /* ERROR "negative" */ 1 :]
|
||||
_ = t[: - /* ERROR "negative" */ 1]
|
||||
_ = t /* ERROR "3-index slice of string" */ [1:2:3]
|
||||
_ = "foo" /* ERROR "3-index slice of string" */ [1:2:3]
|
||||
_ = t[1:2:3 /* ERROR "3-index slice of string" */ ]
|
||||
_ = "foo"[1:2:3 /* ERROR "3-index slice of string" */ ]
|
||||
var t0 byte
|
||||
t0 = t[0]
|
||||
_ = t0
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ func _[T interface{ ~[10]E }, E any] (x T, i, j, k int) { var _ []E = x[i:j:k] }
|
|||
func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j] }
|
||||
func _[T interface{ ~[]byte }] (x T, i, j, k int) { var _ T = x[i:j:k] }
|
||||
func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j] }
|
||||
func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x /* ERROR 3-index slice of string */ [i:j:k] }
|
||||
func _[T interface{ ~string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR 3-index slice of string */ ] }
|
||||
|
||||
type myByte1 []byte
|
||||
type myByte2 []byte
|
||||
|
|
@ -137,7 +137,7 @@ func _[T interface{ []byte | myByte1 | myByte2 }] (x T, i, j, k int) { var _ T =
|
|||
func _[T interface{ []byte | myByte1 | []int }] (x T, i, j, k int) { var _ T = x[ /* ERROR no structural type */ i:j:k] }
|
||||
|
||||
func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j] }
|
||||
func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x /* ERROR 3-index slice of string */ [i:j:k] }
|
||||
func _[T interface{ []byte | myByte1 | myByte2 | string }] (x T, i, j, k int) { var _ T = x[i:j:k /* ERROR 3-index slice of string */ ] }
|
||||
func _[T interface{ []byte | myByte1 | []int | string }] (x T, i, j, k int) { var _ T = x[ /* ERROR no structural type */ i:j] }
|
||||
|
||||
// len/cap built-ins
|
||||
|
|
|
|||
Loading…
Reference in New Issue