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

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

mdempsky opened this issue Aug 19, 2021 · 2 comments
Assignees
Milestone

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Aug 19, 2021

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 this to the Go1.18 milestone Aug 19, 2021
@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 19, 2021

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

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 25, 2021

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

Loading

@gopherbot gopherbot closed this in 4068fb6 Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants