From: Robert Griesemer Date: Wed, 21 Apr 2021 16:04:00 +0000 (-0700) Subject: cmd/compile/internal/types2: fix incorrect result type of Checker.index X-Git-Tag: go1.17beta1~524 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b8a359d984b9b16a405fa66011078a477c6e2da4;p=gostls13.git 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 Run-TryBot: Robert Griesemer Reviewed-by: Robert Findley TryBot-Result: Go Bot --- diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index b9b5b53226..6726272f6c 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -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