-
Notifications
You must be signed in to change notification settings - Fork 18k
go/types, types2: make constraint type inference more flexible for some channel types (?) #45920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that what is most important for now is that the inference rules be as simple as possible. Constraint type inference is already quite complicated. I don't think that we should make it more complicated. There will always be cases where a person can easily see what the answer is even if the inference algorithm can't. |
FWIW here's another case that came up while discussing possible future directions for encoding/json: https://go2goplay.golang.org/p/27Vkw9dnhNZ It would be kinda nice to have constraint type inference work there. |
The good thing about type inference is that we can continue to fine-tune it (and make it more powerful) without affecting existing code (i.e. w/o affecting backward-compatibility). |
For this to work we need to relax the structural type of constraints to ignore channel directions. This may have some unexpected consequences. Will experiment. If the relaxation is all that's needed, we can address this. Otherwise we will stick to the existing rules. |
Removing release-blocker again. We will be ok with or without this. |
Change https://golang.org/cl/363075 mentions this issue: |
Constraint type inference works as expected for
but fails for
per the current proposal specification (constraint type inference expects exactly one type in the type list/set of the constraint for which inference is used).
This seems like it might be a common case; perhaps we need to special case channels that are the same but for their directions.
Reported by @rogpeppe in #43671.
The text was updated successfully, but these errors were encountered: