]> Cypherpunks repositories - gostls13.git/commitdiff
go/types, types2: make sure info recording is executed in test runs
authorRobert Griesemer <gri@golang.org>
Thu, 20 Jul 2023 21:00:20 +0000 (14:00 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 20 Jul 2023 21:16:48 +0000 (21:16 +0000)
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>

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

index 8cb3000501c1d8b094f4d95b3ff6c99317b015b0..94dfda7d33b7e258ef5149dbb5bd6df95524cedd 100644 (file)
@@ -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
index 9093a46a0a94a6754cf8f30864160ea11b0853a4..0841396f358793870dc09929a40730bcdf50952d 100644 (file)
@@ -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