mirror of
https://github.com/golang/go
synced 2024-11-26 11:58:07 -07:00
cmd/compile/internal/types2: fix incorrect result type of Checker.index
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>
This commit is contained in:
parent
f9e2dbbfc9
commit
b8a359d984
@ -349,15 +349,15 @@ func (check *Checker) index(index syntax.Expr, max int64) (typ Type, val int64)
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user