mirror of
https://github.com/golang/go
synced 2024-11-17 13:54:46 -07:00
go/types: print assignment operation for invalid operation errors
This is port of CL 357229 for types2 to go/types. Change-Id: I35ed6b784969210a00ea5b36238df7d6b7fa18bc Reviewed-on: https://go-review.googlesource.com/c/go/+/357230 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
73652af80d
commit
fca46d0b36
@ -1000,7 +1000,11 @@ func (check *Checker) binary(x *operand, e ast.Expr, lhs, rhs ast.Expr, op token
|
||||
if e != nil {
|
||||
posn = e
|
||||
}
|
||||
check.invalidOp(posn, _MismatchedTypes, "%s (mismatched types %s and %s)", e, x.typ, y.typ)
|
||||
if e != nil {
|
||||
check.invalidOp(posn, _MismatchedTypes, "%s (mismatched types %s and %s)", e, x.typ, y.typ)
|
||||
} else {
|
||||
check.invalidOp(posn, _MismatchedTypes, "%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ)
|
||||
}
|
||||
}
|
||||
x.mode = invalid
|
||||
return
|
||||
|
@ -9,3 +9,8 @@ func g() {
|
||||
var i int
|
||||
_ = s /* ERROR invalid operation: s \+ i \(mismatched types string and int\) */ + i
|
||||
}
|
||||
|
||||
func f(i int) int {
|
||||
i /* ERROR invalid operation: i \+= "1" \(mismatched types int and untyped string\) */ += "1"
|
||||
return i
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user