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 """ ,
@@ -2280,4 +2280,34 @@ final class RecoveryTests: XCTestCase {
22802280 )
22812281 }
22822282
2283+ // https://github.com/apple/swift-syntax/issues/1483
2284+ func testRecovery183( ) {
2285+ // Can be parsed and produces no diagnostics.
2286+ assertParse (
2287+ " func f< 1️⃣>() {} " ,
2288+ diagnostics: [
2289+ DiagnosticSpec (
2290+ message: " expected generic parameter in generic parameter clause " ,
2291+ fixIts: [ " insert generic parameter " ]
2292+ )
2293+ ] ,
2294+ fixedSource: """
2295+ func f<<#identifier#> >() {}
2296+ """
2297+ )
2298+
2299+ // Can be parsed. Printing the node or asking for the diagnostics leads to a crash.
2300+ assertParse (
2301+ " func f<1️⃣>() {} " ,
2302+ diagnostics: [
2303+ DiagnosticSpec (
2304+ message: " expected generic parameter in generic parameter clause " ,
2305+ fixIts: [ " insert generic parameter " ]
2306+ )
2307+ ] ,
2308+ fixedSource: """
2309+ func f<<#identifier#>>() {}
2310+ """
2311+ )
2312+ }
22832313}
You can’t perform that action at this time.
0 commit comments