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

cmd/compile: better error message when generics are used with -lang=go1.17 #47818

Closed
mdempsky opened this issue Aug 19, 2021 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@mdempsky
Copy link
Member

Currently, when compiling with -G=3 -lang=go1.17, we run the types2 typechecker, but parse without the AllowGenerics flag. The result is when users try to write generic code, they'll get syntax error messages like unexpected [, expecting (, which seems to be a recurring source of confusion and leaves users (incl. expert Go users) uncertain of how to proceed.

I think we should probably instead always parse with AllowGenerics (at least when we're going to use types2), and have types2 report the usual allowVersion error messages if users try to use generics with go1.17 or earlier.

/cc @griesemer @findleyr

@mdempsky mdempsky added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 19, 2021
@mdempsky mdempsky added this to the Go1.18 milestone Aug 19, 2021
@griesemer
Copy link
Contributor

Agreed. This makes sense now that we're on 1.18. I will take care of this (but I'm ooo until next Monday).

@griesemer griesemer self-assigned this Aug 19, 2021
@griesemer griesemer added NeedsFix The path to resolution is known, but the work has not been done. release-blocker and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Aug 19, 2021
@gopherbot
Copy link

Change https://golang.org/cl/344871 mentions this issue: cmd/compile: always accept 1.18 syntax but complain if not 1.18

@golang golang locked and limited conversation to collaborators Jun 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants