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
$ cat /tmp/x.go
package p
func f(x int, y uint) {
z := x - y
return x > z
}
$ go tool compile -S /tmp/x.go
/tmp/x.go:4: invalid operation: x - y (mismatched types int and uint)
/tmp/x.go:5: too many arguments to return
have (<T>)
want ()
The problem is that z's type is not known, because x-y does not type check
(already reported), and I guess that makes x > z's type not known,
which in turn displays as <T>.
But since the type of the result is not known at all, probably
it's safe not to complain about the argument count for the return at all.
So probably the entire error at line 5 should be suppressed.
@rsc in this case we already got an error on line 4, but am thinking if we suppress the one on
line 5, in the future if we haven't previously encountered an error or if the type is unknown with no
previous error. In cases where the type is unknown, perhaps we can change the message to be like it was in issue #4215 before CL https://go-review.googlesource.com/25156
so that error message will be
$ go tool compile -S /tmp/x.go
/tmp/x.go:4: invalid operation: x - y (mismatched types int and uint)
/tmp/x.go:5: too many arguments to return
and we can still indicate to them that there is an error on that line.
The problem is that z's type is not known, because x-y does not type check
(already reported), and I guess that makes x > z's type not known,
which in turn displays as
<T>
.But since the type of the result is not known at all, probably
it's safe not to complain about the argument count for the return at all.
So probably the entire error at line 5 should be suppressed.
/cc @griesemer @mdempsky
The text was updated successfully, but these errors were encountered: