You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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
% 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.
The text was updated successfully, but these errors were encountered: