Skip to content

Commit 945872e

Browse files
committed
cmd/compile/internal/syntax: added test cases for recent fixes
R=go1.11. Now that we have a syntax error test harness, we can add the proper tests for the recent parser fixes. For #20800. For #20789. For #23385. For #23434. A test for #20789 already exists in test/fixedbugs, but this is the better location for that test. But leaving the existing one where it is as well. Change-Id: I5937b9b63bafd1efab467a00344302e717976171 Reviewed-on: https://go-review.googlesource.com/88336 Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 52fcac3 commit 945872e

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Make sure this doesn't crash the compiler.
6+
// Line 9 must end in EOF for this test (no newline).
7+
8+
package e
9+
func([<-chan<-[func /* ERROR unexpected u */ u){go /* ERROR must be function call */
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Check error message for use of = instead of == .
6+
7+
package p
8+
9+
func f() {
10+
if true || 0 = 1 /* ERROR assignment .* used as value */ {
11+
}
12+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2018 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// Test case for issue 23434: Better synchronization of
6+
// parser after missing type. There should be exactly
7+
// one error each time, with now follow errors.
8+
9+
package p
10+
11+
type T /* ERROR unexpected newline */
12+
13+
type Map map[int] /* ERROR unexpected newline */
14+
15+
// Examples from #23434:
16+
17+
func g() {
18+
m := make(map[string] /* ERROR unexpected ! */ !)
19+
for {
20+
x := 1
21+
print(x)
22+
}
23+
}
24+
25+
func f() {
26+
m := make(map[string] /* ERROR unexpected \) */ )
27+
for {
28+
x := 1
29+
print(x)
30+
}
31+
}

0 commit comments

Comments
 (0)