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: failure to compile dot import #40379

Open
mdempsky opened this issue Jul 24, 2020 · 3 comments
Open

cmd/go2go: failure to compile dot import #40379

mdempsky opened this issue Jul 24, 2020 · 3 comments

Comments

@mdempsky
Copy link
Member

@mdempsky mdempsky commented Jul 24, 2020

I think this program should be okay: https://go2goplay.golang.org/p/WBPOXmHnT9S

But it currently fails to compile with output:

# play
./prog.go2:11: syntax error: unexpected ., expecting expression

Go build failed.

/cc @griesemer

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jul 24, 2020

This type-checks fine. Looks like an issue with the translator.

@griesemer
Copy link
Contributor

@griesemer griesemer commented Jul 24, 2020

This is unrelated to the name of the type parameter, or generic code for that matter. This code has the same problem.

@griesemer griesemer changed the title cmd/go2go: failure to compile type parameter names that shadow dot-imported identifiers cmd/go2go: failure to compile dot import Jul 24, 2020
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jul 24, 2020

This is a bug in the translation tool. It's hard to fix, because go/types doesn't keep track of the package alias, so it's hard for the translation tool to see that the package alias is ".". When rewriting generic the tool needs to qualify lots of identifiers with the package name, and all those qualifications fail with a package alias of ".".

The translation tool is just an experimental tool that isn't expected to handle all possible Go code. I don't think this is an important case, and I don't plan to work on it. If someone wants to send a fix, that would be fine.

Sorry.

@ianlancetaylor ianlancetaylor removed their assignment Jul 24, 2020
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
3 participants
You can’t perform that action at this time.