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: compile error in some cases of method expressions on type parameters #39662

Closed
Carrotman42 opened this issue Jun 17, 2020 · 2 comments

Comments

@Carrotman42
Copy link

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

The Go 2 dev playground at https://go2goplay.golang.org/

What did you do?

Full example: https://go2goplay.golang.org/p/U43Cljg2tvj

Excerpt:

type I interface {
	F()
}

func takesI(type T I)(t T) {
	_ = T.F
}

func workaround(type T I)(t T) {
	_ = (T).F
}

As shown in the full example in the playground link above, calling takesI with T = *SomeType results in compilation failing. Calling workaround is fine, and since the only difference is the manual wrapping of parenthesis this indicates to me that the generated code is just missing grouping of its own which is causing the errors.

What did you see instead?

Error messages during compilation:

./prog.go2:4: invalid method expression P.F (needs pointer receiver: (*P).F)
./prog.go2:4: invalid indirect of V.F (type func(V))
@gopherbot
Copy link

Change https://golang.org/cl/238557 mentions this issue: [dev.go2go] go/go2go: parenthesize type strings

gopherbot pushed a commit that referenced this issue Jun 17, 2020
Fixes #39662

Change-Id: Id176ec00474d66a24e95f2db092f3b4245a93cfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/238557
Reviewed-by: Ian Lance Taylor <iant@golang.org>
@ianlancetaylor
Copy link
Contributor

Thanks. Should be fixed now.

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