File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -465,7 +465,7 @@ extension Parser {
465465 }
466466
467467 precondition ( self . currentToken. starts ( with: " < " ) )
468- let langle = self . consumeAnyToken ( remapping : . leftAngle)
468+ let langle = self . consumePrefix ( " < " , as : . leftAngle)
469469 var elements = [ RawGenericParameterSyntax] ( )
470470 do {
471471 var keepGoing : RawTokenSyntax ? = nil
@@ -477,7 +477,7 @@ extension Parser {
477477 var each = self . consume ( if: . keyword( . each) )
478478
479479 let ( unexpectedBetweenEachAndName, name) = self . expectIdentifier ( allowSelfOrCapitalSelfAsIdentifier: true )
480- if attributes == nil && each == nil && unexpectedBetweenEachAndName == nil && name. isMissing && elements. isEmpty {
480+ if attributes == nil && each == nil && unexpectedBetweenEachAndName == nil && name. isMissing && elements. isEmpty && ! self . currentToken . starts ( with : " > " ) {
481481 break
482482 }
483483
Original file line number Diff line number Diff line change @@ -1066,7 +1066,7 @@ final class RecoveryTests: XCTestCase {
10661066 assertParse (
10671067 """
10681068 // Note: Don't move braces to a different line here.
1069- struct ErrorGenericParameterList4< 1️⃣
1069+ struct ErrorGenericParameterList4<1️⃣
10701070 {
10711071 }
10721072 """ ,
@@ -2286,4 +2286,34 @@ final class RecoveryTests: XCTestCase {
22862286 )
22872287 }
22882288
2289+ // https://github.com/apple/swift-syntax/issues/1483
2290+ func testRecovery183( ) {
2291+ // Can be parsed and produces no diagnostics.
2292+ assertParse (
2293+ " func f< 1️⃣>() {} " ,
2294+ diagnostics: [
2295+ DiagnosticSpec (
2296+ message: " expected generic parameter in generic parameter clause " ,
2297+ fixIts: [ " insert generic parameter " ]
2298+ )
2299+ ] ,
2300+ fixedSource: """
2301+ func f<<#identifier#> >() {}
2302+ """
2303+ )
2304+
2305+ // Can be parsed. Printing the node or asking for the diagnostics leads to a crash.
2306+ assertParse (
2307+ " func f<1️⃣>() {} " ,
2308+ diagnostics: [
2309+ DiagnosticSpec (
2310+ message: " expected generic parameter in generic parameter clause " ,
2311+ fixIts: [ " insert generic parameter " ]
2312+ )
2313+ ] ,
2314+ fixedSource: """
2315+ func f<<#identifier#>>() {}
2316+ """
2317+ )
2318+ }
22892319}
You can’t perform that action at this time.
0 commit comments