Fixes #60906.
Change-Id: Iba117b36041f72a54ce82cc914f8fa3b07a6fb2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/504877
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
if !valid {
check.errorf(e.Pos(), NonSliceableOperand, invalidOp+"cannot index %s", x)
+ check.use(e.Index)
x.mode = invalid
return false
}
if !valid {
// types2 uses the position of '[' for the error
check.errorf(x, NonIndexableOperand, invalidOp+"cannot index %s", x)
+ check.use(e.Indices...)
x.mode = invalid
return false
}
--- /dev/null
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func _() {
+ var x int
+ var f func() []int
+ _ = f /* ERROR "cannot index f" */ [x]
+}