diff mbox

Go patch committed: Better error message for missing comma

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

Commit Message

Ian Lance Taylor Sept. 27, 2012, 5:41 a.m. UTC
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
diff mbox

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;