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
Conversions between interfaces whose concrete types are provably disjoint should be an
error.
http://play.golang.org/p/v8hmUJ909X
gc performs a dynamic check; go/types rejects this program with this error:
a.go:9:6: i (variable of type interface{f(int)}) cannot have dynamic type
interface{f(string)} (wrong type for method f)
The spec doesn't say what should happen. I think this should be a required error,
otherwise it makes "duck typing" very fragile, because adding a parameter to
one interface doesn't and recompiling doesn't detect that the other interface should
have been modified too.
The text was updated successfully, but these errors were encountered:
Sorry, that was reported in haste. To clarify:
- this is about type assertions to interface types, not conversions.
- the spec doesn't mention the possibility of a static error, and does talk about
dynamic types,
so gc is consistent with the spec and go/types is not. Reassigning to gri.
- we probably couldn't change this even if we want to due to the Go 1.1 compatibility
guarantee (and I do want to, because the current behaviour is harmful since it creates
latent dynamic errors when changing one interface but not another.)
- s/interface doesn't/interface/
The text was updated successfully, but these errors were encountered: