]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: enforce Check path restrictions via panics
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 17 Mar 2017 15:05:53 +0000 (15:05 +0000)
committerRobert Griesemer <gri@golang.org>
Fri, 17 Mar 2017 20:32:23 +0000 (20:32 +0000)
Its godoc says that path must not be empty or dot, while the existing
implementation happily accepts both.

Change-Id: I64766271c35152dc7adb21ff60eb05c52237e6b6
Reviewed-on: https://go-review.googlesource.com/38262
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>

src/go/types/api.go

index 7202828f32a40dab0c4623deacb4bdcad87013c6..7b7836fccd4c14178312423cc5cc751d2d8d0806 100644 (file)
@@ -347,6 +347,9 @@ func (init *Initializer) String() string {
 // file set, and the package path the package is identified with.
 // The clean path must not be empty or dot (".").
 func (conf *Config) Check(path string, fset *token.FileSet, files []*ast.File, info *Info) (*Package, error) {
+       if path == "" || path == "." {
+               panic(`path must not be "" or "."`)
+       }
        pkg := NewPackage(path, "")
        return pkg, NewChecker(conf, fset, pkg, info).Files(files)
 }