]> Cypherpunks repositories - gostls13.git/commitdiff
gc: improve error message for composite literals with unexpected newlines
authorRyan Hitchman <hitchmanr@gmail.com>
Mon, 2 Apr 2012 15:00:55 +0000 (11:00 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 2 Apr 2012 15:00:55 +0000 (11:00 -0400)
R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/5857045

src/cmd/gc/go.errors
src/cmd/gc/yerr.h
test/syntax/composite.go [new file with mode: 0644]

index e29cfff5bd498385b096fc0a9a913b97ad1ca010..68a5e5af3aa2b48978c56d2c5ab281fe261e88cd 100644 (file)
@@ -65,6 +65,9 @@ static struct {
        % loadsys package imports LVAR LNAME '=' LNAME '{' LNAME ';'
        "need trailing comma before newline in composite literal",
        
+       % loadsys package imports LVAR LNAME '=' comptype '{' LNAME ';'
+       "need trailing comma before newline in composite literal",
+       
        % loadsys package imports LFUNC LNAME '(' ')' '{' LFUNC LNAME
        "nested func not allowed",
 
index 588890d0edfe0ff06f27cb84ab123841e4b9a54b..256c48b0ec85f1c6d47da279891aca47389d393b 100644 (file)
@@ -65,6 +65,9 @@ static struct {
        425, ';',
        "need trailing comma before newline in composite literal",
        
+       435, ';',
+       "need trailing comma before newline in composite literal",
+       
        112, LNAME,
        "nested func not allowed",
 
diff --git a/test/syntax/composite.go b/test/syntax/composite.go
new file mode 100644 (file)
index 0000000..6565334
--- /dev/null
@@ -0,0 +1,11 @@
+// errorcheck
+
+// Copyright 2012 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package main
+
+var a = []int{
+       3 // ERROR "need trailing comma before newline in composite literal"
+}