mirror of https://github.com/golang/go.git
go/types, types2: call mustParse when using mustTypecheck
Syntactically incorrect source files may produce valid (but unexpected) syntax trees, leading to difficult to understand test failures. Make sure to call mustParse when we call mustTypecheck. Change-Id: I9f5ba3fe57ad3bbc16caabf285d2e7aeb5b9de0c Reviewed-on: https://go-review.googlesource.com/c/go/+/489995 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
parent
6c8ea391cf
commit
972774c444
|
|
@ -49,7 +49,13 @@ func typecheck(path, src string, conf *Config, info *Info) (*Package, error) {
|
|||
}
|
||||
|
||||
func mustTypecheck(path, src string, conf *Config, info *Info) *Package {
|
||||
pkg, err := typecheck(path, src, conf, info)
|
||||
f := mustParse(path, src)
|
||||
if conf == nil {
|
||||
conf = &Config{
|
||||
Importer: defaultImporter(),
|
||||
}
|
||||
}
|
||||
pkg, err := conf.Check(f.PkgName.Value, []*syntax.File{f}, info)
|
||||
if err != nil {
|
||||
panic(err) // so we don't need to pass *testing.T
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,14 @@ func typecheck(path, src string, conf *Config, info *Info) (*Package, error) {
|
|||
}
|
||||
|
||||
func mustTypecheck(path, src string, conf *Config, info *Info) *Package {
|
||||
pkg, err := typecheck(path, src, conf, info)
|
||||
fset := token.NewFileSet()
|
||||
f := mustParse(fset, path, src)
|
||||
if conf == nil {
|
||||
conf = &Config{
|
||||
Importer: importer.Default(),
|
||||
}
|
||||
}
|
||||
pkg, err := conf.Check(f.Name.Name, fset, []*ast.File{f}, info)
|
||||
if err != nil {
|
||||
panic(err) // so we don't need to pass *testing.T
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue