While at it, add missing "invalid argument: " prefix
to a couple of local error messages, for consistency.
For #45667.
Change-Id: I814800b2f3f3750583e335c98a3f8e27030a9daa
Reviewed-on: https://go-review.googlesource.com/c/go/+/312309
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
v, valid := constant.Int64Val(constant.ToInt(x.val))
if !valid || max >= 0 && v >= max {
if check.conf.CompilerErrorMessages {
- check.errorf(&x, "array index %s out of bounds [0:%d]", x.val.String(), max)
+ check.errorf(&x, invalidArg+"array index %s out of bounds [0:%d]", x.val.String(), max)
} else {
- check.errorf(&x, "index %s is out of bounds", &x)
+ check.errorf(&x, invalidArg+"index %s is out of bounds", &x)
}
return
}
// 0 <= v [ && v < max ]
- return Typ[Int], v
+ return x.typ, v
}
// indexElts checks the elements (elts) of an array or slice composite literal