-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
spec: Method sets section doesn't seem quite right for interfaces with type lists #51183
Comments
I'm not sure I completely understand the premise here. This code does work: https://go.dev/play/p/RFUCmHLu964?v=gotip . Sorry if I'm missing something obvious. |
@ianlancetaylor https://go.dev/play/p/ZPFH8EReq1R?v=gotip is what I had in mind. |
Ah, right. Thanks. Certainly the method set of |
Or perhaps the call of |
Maybe, the description should be changed to
(edited) BTW, the following line has become
Here the word |
Should this be a 1.18 release blocker? |
@dominikh The intention (with type sets) has been to make this work, but we haven't gotten to it for 1.18. It's not a release blocker because there are trivial work-arounds: one can always wrap an interface with the necessary methods around the constraint (e.g. your example could be modified like this). Given that we're very late in the release, we probably can't fix this in time (I'll have a look though, maybe it's trivial). We may end up documenting this as temporary restriction. Alternatively, maybe we can adjust the spec slightly and disallow this, but it needs some more thinking. Any less complexity is certainly appreciated. |
I think it'd be simplest to leave the spec as is, and document the restriction. The behavior as described in the specification certainly makes sense and is consistent with the rest of the language. |
Change https://go.dev/cl/387924 mentions this issue: |
For #51183. For #47694. Change-Id: If47ae074c3cd9f73b2e7f6408749d9a7d56bd8d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/387924 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This issue is currently labeled as early-in-cycle for Go 1.19. |
This issue is currently labeled as early-in-cycle for Go 1.20. |
Moving this to 1.23. We hope to lift this and related restrictions eventually (see also #63940). |
Didn't get to #63940, so moving this to 1.24 as well. |
https://tip.golang.org/ref/spec#Method_sets says the following:
AFAIU, per
the type set of
interface { S }
for concrete type S is {S}. The intersection of the method sets is thus the method set of S. But that doesn't seem quite right.func foo[T S](x T) { x.Foo() }
certainly doesn't compile. Was the intention to have an implicit, empty method set for the absent list of methods in the interface?/cc @griesemer @findleyr
The text was updated successfully, but these errors were encountered: