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

@hajimehoshi hajimehoshi commented Jun 17, 2020

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

@ianlancetaylor ianlancetaylor commented Jun 18, 2020

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.

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
2 participants
You can’t perform that action at this time.