mirror of https://github.com/golang/go.git
go/types,types2: allocate the used* maps in initFiles
As described in the associated comment, we need to reallocate usedVars and usedPkgNames in initFiles, as they are nilled out at the end of Checker.Files, which may be called multiple times. Fixes #72122 Change-Id: I9f6eb86e072d9d43a8720f6a5e86d827de6006a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/655437 Auto-Submit: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
d43c0f80d8
commit
fe9b292b11
|
|
@ -315,6 +315,13 @@ func (check *Checker) initFiles(files []*syntax.File) {
|
|||
check.objPath = nil
|
||||
check.cleaners = nil
|
||||
|
||||
// We must initialize usedVars and usedPkgNames both here and in NewChecker,
|
||||
// because initFiles is not called in the CheckExpr or Eval codepaths, yet we
|
||||
// want to free this memory at the end of Files ('used' predicates are
|
||||
// only needed in the context of a given file).
|
||||
check.usedVars = make(map[*Var]bool)
|
||||
check.usedPkgNames = make(map[*PkgName]bool)
|
||||
|
||||
// determine package name and collect valid files
|
||||
pkg := check.pkg
|
||||
for _, file := range files {
|
||||
|
|
|
|||
|
|
@ -339,6 +339,13 @@ func (check *Checker) initFiles(files []*ast.File) {
|
|||
check.objPath = nil
|
||||
check.cleaners = nil
|
||||
|
||||
// We must initialize usedVars and usedPkgNames both here and in NewChecker,
|
||||
// because initFiles is not called in the CheckExpr or Eval codepaths, yet we
|
||||
// want to free this memory at the end of Files ('used' predicates are
|
||||
// only needed in the context of a given file).
|
||||
check.usedVars = make(map[*Var]bool)
|
||||
check.usedPkgNames = make(map[*PkgName]bool)
|
||||
|
||||
// determine package name and collect valid files
|
||||
pkg := check.pkg
|
||||
for _, file := range files {
|
||||
|
|
|
|||
Loading…
Reference in New Issue