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: nonsensical error message with recursive generic interfaces #47837

Closed
4ad opened this issue Aug 20, 2021 · 3 comments
Closed

cmd/compile: nonsensical error message with recursive generic interfaces #47837

4ad opened this issue Aug 20, 2021 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@4ad
Copy link
Member

4ad commented Aug 20, 2021

This is a follow-up to #47836, see that issue first.

On tip (e9e0d1e) with -gcflags=-G=3.

Repro:

package p

type F[t F] interface {
	B() t
}

type Int0 int
type Int1 int

func (n Int0) B() Int1 { return Int1(n) }
func (n Int1) B() Int0 { return Int0(n) }

func id[t F[t]](v t) t { return v }

var _ = id(Int0(42))

Compiler rejects it with:

go build -gcflags=-G=3 j.go
# command-line-arguments
./j.go:15:11: Int0 does not satisfy F[t]: wrong method signature
	got  func (Int0).B() Int1
	want func (F[t ○string]).B() Int0
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2021
@mknyszek mknyszek added this to the Go1.18 milestone Aug 20, 2021
@mknyszek
Copy link
Contributor

CC @ianlancetaylor @griesemer

@griesemer griesemer self-assigned this Aug 22, 2021
@griesemer
Copy link
Contributor

griesemer commented Aug 22, 2021

This is a type checker (types2) failure.

@griesemer
Copy link
Contributor

The compiler is now correctly reporting an error:

cannot use generic type F[t invalid type] without instantiation

This was fixed as part of other fixes. 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