aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/testdata
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2019-03-28 13:32:31 -0700
committerRobert Griesemer <gri@golang.org>2019-04-03 23:01:13 +0000
commit4145c5da1f533fafd928769d18d5be60968cb9dc (patch)
treec4e27fbfaed5069ef881a3068f2e6fbd3d7d5f64 /src/cmd/compile/internal/syntax/testdata
parent9da6530faab0a58c4c4e02b2f3f4a5c754dcbd4e (diff)
downloadgo-4145c5da1f533fafd928769d18d5be60968cb9dc.tar.gz
go-4145c5da1f533fafd928769d18d5be60968cb9dc.zip
cmd/compile: better recovery after := (rather than =) in declarations
Before this fix, a mistaken := in a (const/type/var) declaration ended that declaration with an error from which the parser didn't recover well. This low-cost change will provide a better error message and lets the parser recover perfectly. Fixes #31092. Change-Id: Ic4f94dc5e29dd00b7ef6d53a80dded638e3cea80 Reviewed-on: https://go-review.googlesource.com/c/go/+/169958 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/testdata')
-rw-r--r--src/cmd/compile/internal/syntax/testdata/issue31092.src16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/testdata/issue31092.src b/src/cmd/compile/internal/syntax/testdata/issue31092.src
new file mode 100644
index 0000000000..b1839b8f46
--- /dev/null
+++ b/src/cmd/compile/internal/syntax/testdata/issue31092.src
@@ -0,0 +1,16 @@
+// Copyright 2018 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.
+
+// Test cases for issue 31092: Better synchronization of
+// parser after seeing an := rather than an = in a const,
+// type, or variable declaration.
+
+package p
+
+const _ /* ERROR unexpected := */ := 0
+type _ /* ERROR unexpected := */ := int
+var _ /* ERROR unexpected := */ := 0
+
+const _ int /* ERROR unexpected := */ := 0
+var _ int /* ERROR unexpected := */ := 0