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
When a type isn't compatible with an interface type because it doesn't implement the required methods, the compiler used to mention at least one method that's messing. With the latest tip that's no longer the case - it just says "incompatible type" with no hint as to what's wrong.
For example, with this code:
package main
type I interface {
Foo()
Bar()
}
type S struct{}
func (S) Foo() {
}
func main() {
var _ I = S{}
}
Go 1.17 prints the error:
./tst.go:14:6: cannot use S{} (type S) as type I in assignment:
S does not implement I (missing Bar method)
but Go tip just prints:
./tst.go:14:12: incompatible type: cannot use S{} (value of type S) as I value
Historically I've found the additional information extremely helpful, so I think it should be reinstated.
Aside: I'd actually go further than that - I've often thought that it would be better if the error
showed all the missing methods, not just some arbitrary method, because that gives a better
idea of what's going on.
The text was updated successfully, but these errors were encountered:
commit a83a558
When a type isn't compatible with an interface type because it doesn't implement the required methods, the compiler used to mention at least one method that's messing. With the latest tip that's no longer the case - it just says "incompatible type" with no hint as to what's wrong.
For example, with this code:
Go 1.17 prints the error:
but Go tip just prints:
Historically I've found the additional information extremely helpful, so I think it should be reinstated.
Aside: I'd actually go further than that - I've often thought that it would be better if the error
showed all the missing methods, not just some arbitrary method, because that gives a better
idea of what's going on.
The text was updated successfully, but these errors were encountered: