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: a little inconsistency on uses of type parameters in type parameter lists #51499

go101 opened this issue Mar 5, 2022 · 2 comments


Copy link

@go101 go101 commented Mar 5, 2022

What version of Go are you using (go version)?

$ go version
go version go1.18rc1 linux/amd64

What did you do?

type C1[T []T] struct{} // okay
type C2[T *T] struct{}  // error: undefined: T

What did you expect to see?

Both compiles.

What did you see instead?

The second one doesn't compile.

Not sure if this is intended, just feel they should be consistent.

Copy link

@ianlancetaylor ianlancetaylor commented Mar 5, 2022

CC @griesemer

For 1.19.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation label Mar 5, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Mar 5, 2022
Copy link

@griesemer griesemer commented Mar 5, 2022

This is working correctly according to the spec. The C2 type parameter list is ambiguous and per the spec it is parsed as an (invalid) array declaration since T is unknown. These work:

type C2[T *T,] struct{}
type C3[T interface{*T}] struct{}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants