diff mbox

Go patch committed: Fix enclosing vars for func type in func lit

Message ID mcrlhr31vhg.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Aug. 5, 2014, 3:11 a.m. UTC
This patch to the Go frontend fixes a dumb bug in which the enclosing
vars were incorrectly cleared when a function literal contains a
reference to a function type.  The test for this has been committed to
the master repository: http://codereview.appspot.com/121200043 .  This
fixes PR 61308.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.9 branch.

Ian
diff mbox

Patch

diff -r d7e00d7c498b go/parse.cc
--- a/go/parse.cc	Mon Aug 04 19:56:11 2014 -0700
+++ b/go/parse.cc	Mon Aug 04 19:58:30 2014 -0700
@@ -2870,7 +2870,10 @@ 
   // For a function literal, the next token must be a '{'.  If we
   // don't see that, then we may have a type expression.
   if (!this->peek_token()->is_op(OPERATOR_LCURLY))
-    return Expression::make_type(type, location);
+    {
+      hold_enclosing_vars.swap(this->enclosing_vars_);
+      return Expression::make_type(type, location);
+    }
 
   bool hold_is_erroneous_function = this->is_erroneous_function_;
   if (fntype_is_error)