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: error when a type parameter name and an interface name are same #39659

Closed
hajimehoshi opened this issue Jun 17, 2020 · 1 comment
Closed

Comments

@hajimehoshi
Copy link
Member

What version of Go are you using (go version)?

n/a

Does this issue reproduce with the latest release?

n/a

What operating system and processor architecture are you using (go env)?

n/a

What did you do?

https://go2goplay.golang.org/p/6CjvnnMekvf

package main

type Foo interface{}

func F(type Foo Foo)() {
}

func main() {
}

What did you expect to see?

Compilation succeeds, or a better error message?

What did you see instead?

type checking failed for main
prog.go2:5:17: Foo is not an interface
@ianlancetaylor
Copy link
Contributor

This is expected behavior. It's a consequence of the fact that within a type parameter list, all type parameters are visible throughout the list (https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#mutually-referencing-type-parameters). In (type Foo Foo) the second Foo refers to the first Foo, so it is indeed not an interface type.

CC @griesemer in case he sees a way to get a better error message.

@golang golang locked and limited conversation to collaborators Jun 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants