-
Notifications
You must be signed in to change notification settings - Fork 18k
spec: remove unnecessary syntax restrictions for method expressions to match compiler #9060
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
It appears that both cmd/compile and go/types already accept code like this:
Perhaps we just need to relax the spec. |
This requires more subtle changes in the spec than anticipated - simply removing the grammar in https://golang.org/ref/spec#Method_expressions and replacing MethodExpression with Type in Operand may do it, but then warrant more simplifications (regarding composite literals). Too subtle to squeeze in before 1.7. Still, would be nice to fix since cmd/compile and go/types seem to accept it effortlessly, and it's a clean generalization. But esoteric and of no real use for now, so no urgency. Postponing again. |
It's worth noting that because of type aliases, the formerly syntactically invalid code:
can now equivalently be written as the syntactically valid:
gccgo rejects the former, but accepts the latter. cmd/compile and go/types accept both. Notably though, when |
Removing Go2 label. go/types and cmd/compile accept these forms (and have been accepting them for some time), so at this point this is really just about updating the spec to match the compilers. For the same reasons it's also not a language change. |
Change https://golang.org/cl/73233 mentions this issue: |
Change https://golang.org/cl/73554 mentions this issue: |
For #9060. Change-Id: Ibd0f047083f3c98cec96c655a3e2024df8e1d2a0 Reviewed-on: https://go-review.googlesource.com/73554 Reviewed-by: Ian Lance Taylor <iant@golang.org>
@griesemer I don't know if/how it's related, but when I try the code from #9060 (comment), having the note
in the playground I get
Tried also locally with |
@griesemer Update: Nevermind, I found you've already reported this in #22444. |
Change https://golang.org/cl/81775 mentions this issue: |
This test was added recently as a regress test for the spec relaxation in #9060, but doesn't work correctly yet. Disable for now to fix noopt builders. Updates #22444. Change-Id: I45c521ae0da7ffb0c6859d6f7220c59828ac6149 Reviewed-on: https://go-review.googlesource.com/81775 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
In golang/go#9060, the Go spec was relaxed to allow anonymous receiver types. This CL updates lookdot accordingly.
The text was updated successfully, but these errors were encountered: