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

go/types: inconsistent type checking results with recursive aliases on 1.22 and 1.23 #70230

Open
timothy-king opened this issue Nov 6, 2024 · 4 comments
Assignees
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@timothy-king
Copy link
Contributor

Opening a new issue for #50729 (comment) .

go/types is giving inconsistent errors with recursive aliases on this example https://go.dev/play/p/CO_3yd7yyrV :

type A = E[any]

type X interface {
	G(c A)
}

type E[T any] interface {
	L(A)
}

On the 1.22 playground this fails with the error:

./prog.go:12:4: invalid use of type alias A in recursive type (see go.dev/issue/50729)

Go build failed.

On the 1.23 playground, this fails with the error:

# [play]
vet: ./prog.go:12:4: invalid use of type alias A in recursive type (see go.dev/issue/50729)

Go vet failed.

Program exited.

gotip succeeds and outputs:

Program exited.

On 1.22 and 1.23, commenting out G(c A) makes the vet warning go away. As does moving the declaration of X below E.

cc @griesemer

@cherrymui cherrymui added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 11, 2024
@cherrymui
Copy link
Member

If I understand the post correctly, it looks like the behavior on tip is correct, whereas 1.22 and 1.23 are wrong? So you're suggesting a backport? Thanks.

@cherrymui cherrymui added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Nov 11, 2024
@griesemer
Copy link
Contributor

We may not be able to easily backport a fix because we don't have the same infrastructure (Alias type nodes) enabled in 1.22/23. But this needs to be investigated first.

@griesemer griesemer added this to the Go1.24 milestone Nov 11, 2024
@griesemer griesemer self-assigned this Nov 11, 2024
@cherrymui
Copy link
Member

Thanks. If this only affects recursive aliases like this, we probably don't need to backport.

We need to decide whether tip if correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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