Go patch committed: Only import variable into . if in same package

Message ID CAOyqgcUpfAPSsks68vribxJ6T_A-Wcw7Qt145QKhVgwS1hz7ew@mail.gmail.com
State New
Headers show
Series
  • Go patch committed: Only import variable into . if in same package
Related show

Commit Message

Ian Lance Taylor Sept. 3, 2019, 11:35 p.m.
If the Go frontend sees a dot-import of a package, it should only add
an imported variable to the package bindings if the variable is in the
package being imported.  This patch fixes that.  A test case for this
is the 1.13 os package, in which ErrClosed and friends are defined
both locally and in the imported internal/oserror package.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 275345)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-3b8a505824abb2a69f4c04c555a4ba29ab8b102b
+ca0fdb4c7735a648b8f10f1248631adf9afb8454
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/import.cc
===================================================================
--- gcc/go/gofrontend/import.cc	(revision 275345)
+++ gcc/go/gofrontend/import.cc	(working copy)
@@ -777,7 +777,7 @@  Import::import_var()
 			       this->location_);
   Named_object* no;
   no = vpkg->add_variable(name, var);
-  if (this->add_to_globals_)
+  if (this->add_to_globals_ && vpkg == this->package_)
     this->gogo_->add_dot_import_object(no);
 }