Also: Triaged/adjusted some more test/fixedbugs tests.
Change-Id: Idaba1875273d6da6ef82dd8de8edd8daa885d32c
Reviewed-on: https://go-review.googlesource.com/c/go/+/276472
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
v, valid := constant.Int64Val(constant.ToInt(x.val))
if !valid || max >= 0 && v >= max {
- check.errorf(&x, "index %s is out of bounds", &x)
+ if check.conf.CompilerErrorMessages {
+ check.errorf(&x, "array index %s out of bounds [0:%d]", x.val.String(), max)
+ } else {
+ check.errorf(&x, "index %s is out of bounds", &x)
+ }
return
}
func main() {
printmany(1, 2, 3)
printmany([]int{1, 2, 3}...)
- printmany(1, "abc", []int{2, 3}...) // ERROR "too many arguments in call to printmany\n\thave \(number, string, \.\.\.int\)\n\twant \(...int\)"
+ printmany(1, "abc", []int{2, 3}...) // ERROR "too many arguments in call( to printmany\n\thave \(number, string, \.\.\.int\)\n\twant \(...int\))?"
}
package p
func f1() {
- for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :="
+ for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :=|a redeclared"
println(a)
}
}
func f2() {
var a int
- for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :="
+ for a, a := range []int{1, 2, 3} { // ERROR "a repeated on left side of :=|a redeclared"
println(a)
}
println(a)
func h(int, int) {}
func main() {
- f(g()) // ERROR "in argument to f"
- f(true) // ERROR "in argument to f"
- h(true, true) // ERROR "in argument to h"
+ f(g()) // ERROR "in argument to f|incompatible type"
+ f(true) // ERROR "in argument to f|cannot convert"
+ h(true, true) // ERROR "in argument to h|cannot convert"
}
package main
func main() {
- _ = [0]int{-1: 50} // ERROR "index must be non-negative integer constant"
+ _ = [0]int{-1: 50} // ERROR "index must be non-negative integer constant|must not be negative"
_ = [0]int{0: 0} // ERROR "index 0 out of bounds \[0:0\]"
_ = [0]int{5: 25} // ERROR "index 5 out of bounds \[0:0\]"
_ = [10]int{2: 10, 15: 30} // ERROR "index 15 out of bounds \[0:10\]"
package p
-var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type untyped bool\) as type int in slice literal"
+var _ = []int{a: true, true} // ERROR "undefined: a" "cannot use true \(type untyped bool\) as type int in slice literal|cannot convert true"
func main() {
_ = make([]byte, 1<<bits1)
_ = make([]byte, 1<<bits2)
- _ = make([]byte, nil) // ERROR "non-integer.*len"
- _ = make([]byte, nil, 2) // ERROR "non-integer.*len"
- _ = make([]byte, 1, nil) // ERROR "non-integer.*cap"
- _ = make([]byte, true) // ERROR "non-integer.*len"
- _ = make([]byte, "abc") // ERROR "non-integer.*len"
+ _ = make([]byte, nil) // ERROR "non-integer.*len|untyped nil"
+ _ = make([]byte, nil, 2) // ERROR "non-integer.*len|untyped nil"
+ _ = make([]byte, 1, nil) // ERROR "non-integer.*cap|untyped nil"
+ _ = make([]byte, true) // ERROR "non-integer.*len|untyped bool"
+ _ = make([]byte, "abc") // ERROR "non-integer.*len|untyped string"
}
package main
func main() {
- _ = copy(nil, []int{}) // ERROR "use of untyped nil"
- _ = copy([]int{}, nil) // ERROR "use of untyped nil"
- _ = 1 + true // ERROR "mismatched types untyped int and untyped bool"
+ _ = copy(nil, []int{}) // ERROR "use of untyped nil|untyped nil"
+ _ = copy([]int{}, nil) // ERROR "use of untyped nil|untyped nil"
+ _ = 1 + true // ERROR "mismatched types untyped int and untyped bool|untyped int .* untyped bool"
}
"fixedbugs/issue6703x.go": true,
"fixedbugs/issue6703y.go": true,
"fixedbugs/issue6703z.go": true,
- "fixedbugs/issue6750.go": true,
- "fixedbugs/issue6772.go": true,
- "fixedbugs/issue6889.go": true,
- "fixedbugs/issue7129.go": true,
- "fixedbugs/issue7150.go": true,
- "fixedbugs/issue7153.go": true,
- "fixedbugs/issue7223.go": true,
- "fixedbugs/issue7310.go": true,
- "fixedbugs/issue7525.go": true,
- "fixedbugs/issue7525b.go": true,
- "fixedbugs/issue7525c.go": true,
- "fixedbugs/issue7525d.go": true,
- "fixedbugs/issue7525e.go": true,
+ "fixedbugs/issue6889.go": true, // types2 can handle this without constant overflow
+ "fixedbugs/issue7525.go": true, // init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525b.go": true, // init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525c.go": true, // init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525d.go": true, // init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525e.go": true, // init cycle error on different line - ok otherwise
"fixedbugs/issue7742.go": true, // type-checking doesn't terminate
"fixedbugs/issue7746.go": true, // type-checking doesn't terminate
}