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/compile: bad "cannot declare name" error after dot import #22076

Closed
mdempsky opened this issue Sep 28, 2017 · 2 comments
Closed

cmd/compile: bad "cannot declare name" error after dot import #22076

mdempsky opened this issue Sep 28, 2017 · 2 comments

Comments

@mdempsky
Copy link
Member

This package is valid, but cmd/compile rejects it with "cannot declare name bytes.Buffer":

package p

import . "bytes"

var _ Buffer // used import "bytes"

func f() {
        Buffer := 0
        _ = Buffer
}
@mdempsky
Copy link
Member Author

This is similar to #22072, but likely easier to fix.

The root problem is when we have an assignment like x := y we're noding the left-hand side (x) like it's a general Go expression (using exprList), but then later we apply colasdefn to re-declare identifiers as appropriate.

Instead noder should probably apply colasdefn's logic directly to the package syntax AST.

@gopherbot
Copy link

Change https://golang.org/cl/66810 mentions this issue: cmd/compile: allow := to shadow dot-imported names

@golang golang locked and limited conversation to collaborators Oct 5, 2018
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

2 participants