From 8a686792e08f1114fd7819a32d8c2e3c4ddddc14 Mon Sep 17 00:00:00 2001 From: Ryan Hitchman Date: Mon, 2 Apr 2012 11:00:55 -0400 Subject: [PATCH] gc: improve error message for composite literals with unexpected newlines R=golang-dev, r, rsc CC=golang-dev https://golang.org/cl/5857045 --- src/cmd/gc/go.errors | 3 +++ src/cmd/gc/yerr.h | 3 +++ test/syntax/composite.go | 11 +++++++++++ 3 files changed, 17 insertions(+) create mode 100644 test/syntax/composite.go diff --git a/src/cmd/gc/go.errors b/src/cmd/gc/go.errors index e29cfff5bd..68a5e5af3a 100644 --- a/src/cmd/gc/go.errors +++ b/src/cmd/gc/go.errors @@ -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", diff --git a/src/cmd/gc/yerr.h b/src/cmd/gc/yerr.h index 588890d0ed..256c48b0ec 100644 --- a/src/cmd/gc/yerr.h +++ b/src/cmd/gc/yerr.h @@ -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 index 0000000000..6565334935 --- /dev/null +++ b/test/syntax/composite.go @@ -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" +}