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
I have tried four ways to convert string type back to generic type when the generic type is string. The last one with *string success.
I think it is too difficult for a new user to finish this task.
It may be good to just allow my first try success when the dst_t is string and compile error when the dst_t is not string.
No, I do not want "type switching on type parameters" in this proposal.
I want allow convert string type back to generic type when the generic type is string.
It is not same thing.
I think it is linked to type parameter switches but that's an interesting issue.
The current implementation considers that the type parameter is an interface with the dynamic type being fixed at instantiation.
So dst_t is not string but its dynamic type is which is what you are testing here. That's why I think the conversion does not work, nor does returning a string.
Maybe it should be treated as an existential type rather, in spite of how it is implemented.
This is a dup of type switches on type parameters because you are looking for a way to treat a type parameter specially based on a type switch on that type parameter. You want to be able to say that in case string the compiler should know that the type is string. That is part of #45380.
Today the compiler does not know assume anything based on a type switch.
I have tried four ways to convert string type back to generic type when the generic type is string. The last one with
*string
success.I think it is too difficult for a new user to finish this task.
It may be good to just allow my first try success when the dst_t is string and compile error when the dst_t is not string.
Here is my code: https://go.dev/play/p/Bst6mDAjN7g
The text was updated successfully, but these errors were encountered: