Patchwork Go patch committed: Better error message for missing comma

login
register
mail settings
Submitter Ian Taylor
Date Sept. 27, 2012, 5:41 a.m.
Message ID <mcrbogsf2e7.fsf@google.com>
Download mbox | patch
Permalink /patch/187280/
State New
Headers show

Comments

Ian Taylor - Sept. 27, 2012, 5:41 a.m.
This patch to the Go frontend gives a better error message for a missing
comma in a composite literal.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline and 4.7 branch.

Ian

Patch

diff -r f47f5449a663 go/parse.cc
--- a/go/parse.cc	Mon Sep 24 15:20:45 2012 -0700
+++ b/go/parse.cc	Wed Sep 26 22:21:36 2012 -0700
@@ -2723,7 +2723,11 @@ 
 	}
       else
 	{
-	  error_at(this->location(), "expected %<,%> or %<}%>");
+	  if (token->is_op(OPERATOR_SEMICOLON))
+	    error_at(this->location(),
+		     "need trailing comma before newline in composite literal");
+	  else
+	    error_at(this->location(), "expected %<,%> or %<}%>");
 
 	  this->gogo_->mark_locals_used();
 	  int depth = 0;