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
funcf[P~*T, Tany]() {
varpPvartp*Ttp=p// <<< ERROR HERE
}
is currently not permitted:
cannot use p (variable of type P constrained by ~*T) as type *T in assignment:
P does not implement *T (type *T is pointer to interface, not interface)
because type parameters are following the rules for interfaces in this assignment (their constraints are interfaces). This ties in with the question of what the underlying type of a type parameter is (currently it's the constraint interface); the rest follows from that.
This may not be the right approach for type parameters; or at least not the most user-friendly approach.
This appears to be just a bug in the assignment check.
[edited]
is currently not permitted:
because type parameters are following the rules for interfaces in this assignment (their constraints are interfaces). This ties in with the question of what the underlying type of a type parameter is (currently it's the constraint interface); the rest follows from that.This may not be the right approach for type parameters; or at least not the most user-friendly approach.This appears to be just a bug in the assignment check.
cc: @rsc (who raised the issue)
cc: @findleyr @ianlancetaylor
The text was updated successfully, but these errors were encountered: