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

Closed
zigo101 opened this issue Mar 5, 2022 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@zigo101
Copy link

zigo101 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.

@ianlancetaylor
Copy link
Member

CC @griesemer

For 1.19.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 5, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Mar 5, 2022
@griesemer
Copy link
Contributor

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{}

@golang golang locked and limited conversation to collaborators Mar 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants