Patchwork Go patch committed: Fix invalid signature in function literal

login
register
mail settings
Submitter Ian Taylor
Date Dec. 15, 2010, 10:42 p.m.
Message ID <mcr8vzq1wva.fsf@google.com>
Download mbox | patch
Permalink /patch/75701/
State New
Headers show

Comments

Ian Taylor - Dec. 15, 2010, 10:42 p.m.
This patch to the Go frontend fixes the way we handle an invalid
signature for a function literal.  Rather than trying to parse the block
without creating a function, which fails if there is a return statement,
we instead just create a dummy function type.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Patch

diff -r 70dbc32f9149 go/parse.cc
--- a/go/parse.cc	Wed Dec 15 14:30:06 2010 -0800
+++ b/go/parse.cc	Wed Dec 15 14:38:25 2010 -0800
@@ -2513,10 +2513,7 @@ 
 
   Function_type* type = this->signature(NULL, location);
   if (type == NULL)
-    {
-      this->block();
-      return Expression::make_error(location);
-    }
+    type = Type::make_function_type(NULL, NULL, NULL, location);
 
   // For a function literal, the next token must be a '{'.  If we
   // don't see that, then we may have a type expression.