Commit ca2ae27d authored by Robert Griesemer's avatar Robert Griesemer

go/ast: multiple "blank" imports are permitted

R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/6303099
parent 9c975440
...@@ -203,7 +203,7 @@ func check(t *testing.T, testname string, testfiles []string) { ...@@ -203,7 +203,7 @@ func check(t *testing.T, testname string, testfiles []string) {
func TestCheck(t *testing.T) { func TestCheck(t *testing.T) {
// For easy debugging w/o changing the testing code, // For easy debugging w/o changing the testing code,
// if there is a local test file, only test that file. // if there is a local test file, only test that file.
const testfile = "test.go" const testfile = "testdata/test.go"
if fi, err := os.Stat(testfile); err == nil && !fi.IsDir() { if fi, err := os.Stat(testfile); err == nil && !fi.IsDir() {
fmt.Printf("WARNING: Testing only %s (remove it to run all tests)\n", testfile) fmt.Printf("WARNING: Testing only %s (remove it to run all tests)\n", testfile)
check(t, testfile, []string{testfile}) check(t, testfile, []string{testfile})
......
...@@ -6,7 +6,12 @@ ...@@ -6,7 +6,12 @@
package test0 package test0
import "unsafe" import (
"unsafe"
// we can have multiple blank imports (was bug)
_ "math"
_ "net/rpc"
)
const pi = 3.1415 const pi = 3.1415
......
...@@ -136,7 +136,7 @@ func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer, ...@@ -136,7 +136,7 @@ func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer,
for _, obj := range pkg.Data.(*Scope).Objects { for _, obj := range pkg.Data.(*Scope).Objects {
p.declare(fileScope, pkgScope, obj) p.declare(fileScope, pkgScope, obj)
} }
} else { } else if name != "_" {
// declare imported package object in file scope // declare imported package object in file scope
// (do not re-use pkg in the file scope but create // (do not re-use pkg in the file scope but create
// a new object instead; the Decl field is different // a new object instead; the Decl field is different
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment