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

types2, go/types: self-referential type parameter list is not accepted #47796

Closed
griesemer opened this issue Aug 18, 2021 · 3 comments
Closed

types2, go/types: self-referential type parameter list is not accepted #47796

griesemer opened this issue Aug 18, 2021 · 3 comments
Assignees
Milestone

Comments

@griesemer
Copy link
Contributor

@griesemer griesemer commented Aug 18, 2021

Example:

package p
type Eq[a Eq[a]] interface {
	Equal(that a) bool
}

produces

:2:13: Eq is not a generic type

Should this be permitted?

cc: @ianlancetaylor

@griesemer griesemer added this to the Go1.18 milestone Aug 18, 2021
@griesemer griesemer self-assigned this Aug 18, 2021
@griesemer
Copy link
Contributor Author

@griesemer griesemer commented Aug 18, 2021

In any case, the error message needs to be fixed. Eq is a generic type.

Loading

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Aug 19, 2021

I can't think of a reason to forbid this. It seems well-defined. It would be more problematic in a function definition, where we would have to derive an operation set, but of course this can't happen in a function definition and the problem doesn't arise in a type definition.

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 7, 2021

Change https://golang.org/cl/348090 mentions this issue: cmd/compile/internal/types2: handle recursive type parameter constraints

Loading

@gopherbot gopherbot closed this in 73a062c Sep 8, 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