...

Source file src/cmd/compile/internal/syntax/testdata/issue23434.go

Documentation: cmd/compile/internal/syntax/testdata

     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 go.dev/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 go.dev/issue/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  }
    32  

View as plain text