// only report an error if we have valid types
// (otherwise we had an error reported elsewhere already)
if x.typ != Typ[Invalid] && y.typ != Typ[Invalid] {
- check.errorf(x, invalidOp+"mismatched types %s and %s", x.typ, y.typ)
+ check.errorf(x, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ)
}
x.mode = invalid
return
--- /dev/null
+// Copyright 2021 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 g() {
+ var s string
+ var i int
+ _ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i
+}
if e != nil {
posn = e
}
- check.invalidOp(posn, _MismatchedTypes, "mismatched types %s and %s", x.typ, y.typ)
+ check.invalidOp(posn, _MismatchedTypes, "%s (mismatched types %s and %s)", e, x.typ, y.typ)
}
x.mode = invalid
return
--- /dev/null
+// Copyright 2021 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 g() {
+ var s string
+ var i int
+ _ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i
+}