}
check.exprOrType(x, e.X, false)
- if x.mode == invalid {
+ switch x.mode {
+ case builtin:
+ check.errorf(e.Pos(), "cannot select on %s", x)
+ goto Error
+ case invalid:
goto Error
}
}
if !valid {
- check.errorf(x, invalidOp+"cannot index %s", x)
+ check.errorf(e.Pos(), invalidOp+"cannot index %s", x)
x.mode = invalid
return false
}
--- /dev/null
+// Copyright 2022 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 _() {
+ len. /* ERROR cannot select on len */ Println
+ len. /* ERROR cannot select on len */ Println()
+ _ = len. /* ERROR cannot select on len */ Println
+ _ = len[ /* ERROR cannot index len */ 0]
+ _ = *len /* ERROR cannot indirect len */
+}
}
check.exprOrType(x, e.X, false)
- if x.mode == invalid {
+ switch x.mode {
+ case builtin:
+ // types2 uses the position of '.' for the error
+ check.errorf(e.Sel, _UncalledBuiltin, "cannot select on %s", x)
+ goto Error
+ case invalid:
goto Error
}
}
if !valid {
+ // types2 uses the position of '[' for the error
check.invalidOp(x, _NonIndexableOperand, "cannot index %s", x)
x.mode = invalid
return false
--- /dev/null
+// Copyright 2022 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 _() {
+ len.Println /* ERROR cannot select on len */
+ len.Println /* ERROR cannot select on len */ ()
+ _ = len.Println /* ERROR cannot select on len */
+ _ = len /* ERROR cannot index len */ [0]
+ _ = *len /* ERROR cannot indirect len */
+}