You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: better error message when generics are used with -lang=go1.17 #47818
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.
Activity
griesemer commentedon 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).
gopherbot commentedon Aug 25, 2021
Change https://golang.org/cl/344871 mentions this issue:
cmd/compile: always accept 1.18 syntax but complain if not 1.18cmd/compile: always accept 1.18 syntax but complain if not 1.18