You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
type C interface {
int32
}
func inc[T C](x T) T {
x++
return x
}
func main() {
println(inc(int32(5)))
}
$ go run -gcflags=-G=3 ~/gowork/tmp2.go
# command-line-arguments
../../../gowork/tmp2.go:8:3: invalid operation: x + 1 (mismatched types int32 and int)
../../../gowork/tmp2.go:12:13: invalid operation: x + 1 (mismatched types int32 and int)
I think the 1 introduced by ++ needs to have the type of the LHS.
…h generic type
types2 will have already proved the expression's type is compatible, so
just assign the one const to have the same type as the operand.
Fixes#47258.
Change-Id: If0844e6bf6d0a5e6b11453b87df71353863ccc5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/336009
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
I think the
1
introduced by++
needs to have the type of the LHS.Not sure why there are two errors also.
@danscales
The text was updated successfully, but these errors were encountered: