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
$ cat /tmp/x.go
package p
func f() {
_ = func() {
var x int
}
}
$ go get golang.org/x/tools/cmd/gotype
$ gotype /tmp/x.go
x.go:5:7: x declared but not used
x.go:5:7: x declared but not used
$
The error should be reported by go/types only once.
The issue here is that we're checking the function literal scope twice. Ideally, we would know that this particular child of the f scope is a function literal that will be type-checked later, so we shouldn't recurse into it in Checker.usage. I haven't found a way to do that.
We could also keep a map of what scopes we have already type-checked to avoid duplicates, but that seems unnecessarily wasteful.
I don't see a clear fix here, so leaving it to someone else. Or, if anyone has any hints, I can have a second go at it.
The error should be reported by go/types only once.
/cc @griesemer
The text was updated successfully, but these errors were encountered: