Skip to content
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

go/types, types2: disable inference for instances of defined types (not functions) for 1.18 #51527

Closed
findleyr opened this issue Mar 7, 2022 · 2 comments
Labels
FrozenDueToAge generics Issue is related to generics NeedsFix The path to resolution is known, but the work has not been done. release-blocker TypeInference Issue is related to generic type inference
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Mar 7, 2022

Note: this issue pertains only to inference of type arguments for defined types, NOT for functions.

E.g., the following currently works.

type T[P any, Q *P] int

var _ T[string]  // right now, the second type argument may be elided

https://go.dev/play/p/ZCGoJ494neo?v=gotip

This feature was considered a "nice to have" for 1.18, due to symmetry with function type inference. However, resolving type instances is more complex than resolving function instances, due to recursive declarations, and recently we've seen bugs related to "type-type inference" that manifest in confusing ways (e.g. #51233 or #51489).

In consideration of the timing, we've decided to disable this feature for 1.18.

CC @griesemer @ianlancetaylor @rsc

@findleyr findleyr added NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Mar 7, 2022
@findleyr findleyr added this to the Go1.18 milestone Mar 7, 2022
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/387934 mentions this issue: go/types, types2: disable inference for type instances

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/390576 mentions this issue: [release-branch.go1.18] go/types, types2: disable inference for type instances

gopherbot pushed a commit that referenced this issue Mar 8, 2022
…instances

Inference for type instances has dependencies on type-checking order
that can lead to subtle bugs. As explained in #51527, disable it for
1.18.

Fixes #51527

Change-Id: I42795bad30ce53abecfc5a4914599ae5a2041a9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/387934
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 28fab5e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390576
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
@ianlancetaylor ianlancetaylor added TypeInference Issue is related to generic type inference generics Issue is related to generics labels Apr 18, 2022
@golang golang locked and limited conversation to collaborators Apr 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge generics Issue is related to generics NeedsFix The path to resolution is known, but the work has not been done. release-blocker TypeInference Issue is related to generic type inference
Projects
None yet
Development

No branches or pull requests

3 participants