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 @@ -1031,7 +1031,7 @@ final class RecoveryTests: XCTestCase {
10311031 assertParse (
10321032 """
10331033 // Note: Don't move braces to a different line here.
1034- struct ErrorGenericParameterList4< 1️⃣
1034+ struct ErrorGenericParameterList4<1️⃣
10351035 {
10361036 }
10371037 """ ,
@@ -2245,4 +2245,34 @@ final class RecoveryTests: XCTestCase {
22452245 )
22462246 }
22472247
2248+ // https://github.com/apple/swift-syntax/issues/1483
2249+ func testRecovery183( ) {
2250+ // Can be parsed and produces no diagnostics.
2251+ assertParse (
2252+ " func f< 1️⃣>() {} " ,
2253+ diagnostics: [
2254+ DiagnosticSpec (
2255+ message: " expected generic parameter in generic parameter clause " ,
2256+ fixIts: [ " insert generic parameter " ]
2257+ )
2258+ ] ,
2259+ fixedSource: """
2260+ func f<<#identifier#> >() {}
2261+ """
2262+ )
2263+
2264+ // Can be parsed. Printing the node or asking for the diagnostics leads to a crash.
2265+ assertParse (
2266+ " func f<1️⃣>() {} " ,
2267+ diagnostics: [
2268+ DiagnosticSpec (
2269+ message: " expected generic parameter in generic parameter clause " ,
2270+ fixIts: [ " insert generic parameter " ]
2271+ )
2272+ ] ,
2273+ fixedSource: """
2274+ func f<<#identifier#>>() {}
2275+ """
2276+ )
2277+ }
22482278}
You can’t perform that action at this time.
0 commit comments