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/go2go: nonsensical recursive type compiles #40884

Closed
benjaminjkraft opened this issue Aug 19, 2020 · 1 comment
Closed

cmd/go2go: nonsensical recursive type compiles #40884

benjaminjkraft opened this issue Aug 19, 2020 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@benjaminjkraft
Copy link

benjaminjkraft commented Aug 19, 2020

Here are two types (playground):

type A[type X] interface{ a(X) }
type B[type X A[B]] interface{ b(X) }

The type A[B] is semantically invalid; B needs to be instantiated. But this seems to be allowed currently.

In fact if we modify A a bit we can even supposedly implement B (playground):

type A[type X] interface{ b(B[X]) }
type B[type X A[B]] interface{ b(X) }
type S struct{}
func (_ S) b(A[int]) {}
var _ B[A[int]] = S{}
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 19, 2020
@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Aug 19, 2020
@griesemer
Copy link
Contributor

This code now reports a proper cycle error (playground). Closing.

@golang golang locked and limited conversation to collaborators Jun 23, 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