Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
2 changed files
with
34 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |