Go patch committed: Fix invalid signature in function literal

Submitted by Ian Taylor on Dec. 15, 2010, 10:42 p.m.

Details

Message ID mcr8vzq1wva.fsf@google.com
State New
Headers show

Commit Message

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 hide | download patch | download mbox

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.