Skip to content

Commit

Permalink
go/types, types2: make sure info recording is executed in test runs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
griesemer authored and gopherbot committed Jul 20, 2023
1 parent 57e2eb6 commit 7b625d1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/cmd/compile/internal/types2/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,17 @@ func testFiles(t *testing.T, filenames []string, srcs [][]byte, colDelta uint, m
opt(&conf)
}

conf.Check(pkgName, files, nil)
// Provide Config.Info with all maps so that info recording is tested.
info := Info{
Types: make(map[syntax.Expr]TypeAndValue),
Instances: make(map[*syntax.Name]Instance),
Defs: make(map[*syntax.Name]Object),
Uses: make(map[*syntax.Name]Object),
Implicits: make(map[syntax.Node]Object),
Selections: make(map[*syntax.SelectorExpr]*Selection),
Scopes: make(map[syntax.Node]*Scope),
}
conf.Check(pkgName, files, &info)

if listErrors {
return
Expand Down
12 changes: 11 additions & 1 deletion src/go/types/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,17 @@ func testFiles(t *testing.T, filenames []string, srcs [][]byte, manual bool, opt
opt(&conf)
}

conf.Check(pkgName, fset, files, nil)
// Provide Config.Info with all maps so that info recording is tested.
info := Info{
Types: make(map[ast.Expr]TypeAndValue),
Instances: make(map[*ast.Ident]Instance),
Defs: make(map[*ast.Ident]Object),
Uses: make(map[*ast.Ident]Object),
Implicits: make(map[ast.Node]Object),
Selections: make(map[*ast.SelectorExpr]*Selection),
Scopes: make(map[ast.Node]*Scope),
}
conf.Check(pkgName, fset, files, &info)

if listErrors {
return
Expand Down

0 comments on commit 7b625d1

Please sign in to comment.