]> Cypherpunks repositories - gostls13.git/commit
go/types: avoid repeated "declared but not used" errors for closure variables
authorgriesemer <gri@golang.org>
Wed, 1 Nov 2017 21:24:06 +0000 (14:24 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 1 Nov 2017 21:59:33 +0000 (21:59 +0000)
commita0dfd82f41145bd41b765d9fb13bc2c10c659571
treedbb05d0c8759dd014c716e46c76a3d5f812636e1
parenteb2b0ed5b59cfb340de0118235bfda60e0de4a8d
go/types: avoid repeated "declared but not used" errors for closure variables

At the end of type-checking a function or closure, unused local variables
are reported by looking at all variables in the function scope and its
nested children scopes. If a nested scope belonged to a nested function
(closure), that scope would be searched twice, leading to multiple error
messages for unused variables.

This CL introduces an internal-only marker to identify function scopes
so that they can be ignored where needed.

Fixes #22524.

Change-Id: If58cc17b2f0615a16f33ea262f50dffd0e86d0f0
Reviewed-on: https://go-review.googlesource.com/75251
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/expr.go
src/go/types/scope.go
src/go/types/stmt.go
src/go/types/testdata/vardecl.src
src/go/types/typexpr.go