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

go/types: missing "unused var" error due to incorrect scope computation #9570

Closed
alandonovan opened this issue Jan 12, 2015 · 1 comment
Closed
Assignees

Comments

@alandonovan
Copy link
Contributor

@alandonovan alandonovan commented Jan 12, 2015

% cat a.go
package main

type I interface {
f() chan int
}

func f(i I) {
select {
case <-chan int(nil):
var i I // unused, but no error
case <-i.f(): // delete this case, and you'll see the error
}
}
% gotype a.go && echo PASS
PASS

The real problem here is not the failure to report an error, but a mistake in the scope calculation.
I think go/types is treating the reference to i in the second case as if it is within the scope of the 'var i I' declaration, in other words, it's resolving to the wrong i.

I think this explains SSA bug #9569 too.

@alandonovan
Copy link
Contributor Author

@alandonovan alandonovan commented Jan 12, 2015

Loading

@mikioh mikioh changed the title x/tools/go/types: missing "unused var" error due to incorrect scope computation go/types: missing "unused var" error due to incorrect scope computation Jan 12, 2015
@griesemer griesemer closed this Jan 13, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants