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
This fails to compile with the following message: "cannot use 1 (type int) as type A in assignment: int does not implement A (missing Read method)"
The problem is that 'int' also misses the 'Write' method, but it is not disclosed until user works around by defining a custom type and implementing the missing method (only to realize that it was not the only one).
This behavior delivers surprises when using complex libraries and writing compartibility layers for them.
The text was updated successfully, but these errors were encountered:
mdempsky
changed the title
Assigning to interface variable mentions only first missing method.
cmd/compile: assigning to interface variable mentions only first missing method
Dec 9, 2015
If there's only a couple missing methods, it seems reasonable to mention them all. But I don't think we want to list all 29 missing methods for:
var x reflect.Type = 1
Maybe something like this though?
cannot use 1 (type int) as type reflect.Type in assignment: int does not implement reflect.Type (missing Align, FieldAlign, Method, MethodByName, and 25 more methods)
Consider the following code (http://play.golang.org/p/0Sm13cKcq5):
This fails to compile with the following message:
"cannot use 1 (type int) as type A in assignment: int does not implement A (missing Read method)"
The problem is that 'int' also misses the 'Write' method, but it is not disclosed until user works around by defining a custom type and implementing the missing method (only to realize that it was not the only one).
This behavior delivers surprises when using complex libraries and writing compartibility layers for them.
The text was updated successfully, but these errors were encountered: