]> Cypherpunks repositories - gostls13.git/commitdiff
go/ast: multiple "blank" imports are permitted
authorRobert Griesemer <gri@golang.org>
Tue, 19 Jun 2012 04:56:41 +0000 (21:56 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 19 Jun 2012 04:56:41 +0000 (21:56 -0700)
R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/6303099

src/pkg/exp/types/check_test.go
src/pkg/exp/types/testdata/test0.src
src/pkg/go/ast/resolve.go

index 34c26c9908cff68c55735009192f9a9a5dd0d0e1..03cc7438e2e24ef66e22a6eae1dcfc3aaa0f6ef8 100644 (file)
@@ -203,7 +203,7 @@ func check(t *testing.T, testname string, testfiles []string) {
 func TestCheck(t *testing.T) {
        // For easy debugging w/o changing the testing code,
        // 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() {
                fmt.Printf("WARNING: Testing only %s (remove it to run all tests)\n", testfile)
                check(t, testfile, []string{testfile})
index 84a1abe27013251a6826f8ca0524486bc9453601..876573481b96c0c4f9c6b074d17b34860457c244 100644 (file)
@@ -6,7 +6,12 @@
 
 package test0
 
-import "unsafe"
+import (
+       "unsafe"
+       // we can have multiple blank imports (was bug)
+       _ "math"
+       _ "net/rpc"
+)
 
 const pi = 3.1415
 
index 908e61c5da01d71560449ebb777d5d3bd1405154..54b5d73252d1b8d417e21bf37aedb9c66e831b23 100644 (file)
@@ -136,7 +136,7 @@ func NewPackage(fset *token.FileSet, files map[string]*File, importer Importer,
                                for _, obj := range pkg.Data.(*Scope).Objects {
                                        p.declare(fileScope, pkgScope, obj)
                                }
-                       } else {
+                       } else if name != "_" {
                                // declare imported package object in file scope
                                // (do not re-use pkg in the file scope but create
                                // a new object instead; the Decl field is different