-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: underscore type names cause panic #39743
Comments
commit d872bbc https://go2goplay.golang.org/p/7tn_5lE9y4k Here's a different panic, perhaps with the same underlying cause:
This panics with the following stack trace:
|
@griesemer The problem here is that the translation tool doesn't know that func (f Foo(_)) X() {} is the declaration of a method of a parameterized type. The tool tries to figure that out by asking for the Any thoughts on the best way to determine, based only on the AST, that this method declaration is for a parameterized type? Thanks. |
A receiver is both a declaration of the (local) type parameter names and, for the type checker to work uniformly, an instantiation of the receiver's base type with those parameter names. That instantiation would fail if we were using func (recv T(P, _, _, R, _)) m() { ... } get renamed to func (recv T(P, 1_, 2_, R, 4_)) m() { ... } Hope that helps. |
Change https://golang.org/cl/239382 mentions this issue: |
The translation tool is trying to look up the type given an This will now give an error message on the dev.go2go branch. |
The go/types package doesn't give us an easy way to get the type, so just reject it. Fixes #39743 Change-Id: I5404c10baede0fd2cf67980b06fbebd214a50dff Reviewed-on: https://go-review.googlesource.com/c/go/+/239382 Reviewed-by: Ian Lance Taylor <iant@golang.org>
commit d872bbc
https://go2goplay.golang.org/p/z4dUhE98Co0
The following program panics:
The panic message is:
The proposal specifically suggests that
_
is an OK name for type parameters, so this should be valid.The text was updated successfully, but these errors were encountered: