Skip to content

Commit 7b625d1

Browse files
griesemergopherbot
authored andcommitted
go/types, types2: make sure info recording is executed in test runs
Issue #61486 causes a compiler crash but is not detected when running stand-alone type-checker tests because no types are recorded. Set up Config.Info map with all maps when when running local tests so that type/object recording code is executed during local tests. For #61486. Change-Id: I8eb40c8525dac3da65db0dc7e0e654842713b9a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/511657 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
1 parent 57e2eb6 commit 7b625d1

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/cmd/compile/internal/types2/check_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,17 @@ func testFiles(t *testing.T, filenames []string, srcs [][]byte, colDelta uint, m
163163
opt(&conf)
164164
}
165165

166-
conf.Check(pkgName, files, nil)
166+
// Provide Config.Info with all maps so that info recording is tested.
167+
info := Info{
168+
Types: make(map[syntax.Expr]TypeAndValue),
169+
Instances: make(map[*syntax.Name]Instance),
170+
Defs: make(map[*syntax.Name]Object),
171+
Uses: make(map[*syntax.Name]Object),
172+
Implicits: make(map[syntax.Node]Object),
173+
Selections: make(map[*syntax.SelectorExpr]*Selection),
174+
Scopes: make(map[syntax.Node]*Scope),
175+
}
176+
conf.Check(pkgName, files, &info)
167177

168178
if listErrors {
169179
return

src/go/types/check_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,17 @@ func testFiles(t *testing.T, filenames []string, srcs [][]byte, manual bool, opt
178178
opt(&conf)
179179
}
180180

181-
conf.Check(pkgName, fset, files, nil)
181+
// Provide Config.Info with all maps so that info recording is tested.
182+
info := Info{
183+
Types: make(map[ast.Expr]TypeAndValue),
184+
Instances: make(map[*ast.Ident]Instance),
185+
Defs: make(map[*ast.Ident]Object),
186+
Uses: make(map[*ast.Ident]Object),
187+
Implicits: make(map[ast.Node]Object),
188+
Selections: make(map[*ast.SelectorExpr]*Selection),
189+
Scopes: make(map[ast.Node]*Scope),
190+
}
191+
conf.Check(pkgName, fset, files, &info)
182192

183193
if listErrors {
184194
return

0 commit comments

Comments
 (0)