aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/expr.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2020-12-08 17:48:39 -0800
committerRobert Griesemer <gri@golang.org>2020-12-09 23:54:59 +0000
commit810957b1555358fd22e6dfd75cdceb2117362f91 (patch)
treece6342717b83cc898b33b2bbc4d08c5dd3333a30 /src/cmd/compile/internal/types2/expr.go
parentc32566c336519f378c07575b0149507a261032e9 (diff)
downloadgo-810957b1555358fd22e6dfd75cdceb2117362f91.tar.gz
go-810957b1555358fd22e6dfd75cdceb2117362f91.zip
[dev.typeparams] cmd/compile/internal/types2: adjusted array error message for compiler
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>
Diffstat (limited to 'src/cmd/compile/internal/types2/expr.go')
-rw-r--r--src/cmd/compile/internal/types2/expr.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go
index c68077547e..bede0c639d 100644
--- a/src/cmd/compile/internal/types2/expr.go
+++ b/src/cmd/compile/internal/types2/expr.go
@@ -1039,7 +1039,11 @@ 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 {
- 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
}