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 {
465
465
}
466
466
467
467
precondition ( self . currentToken. starts ( with: " < " ) )
468
- let langle = self . consumeAnyToken ( remapping : . leftAngle)
468
+ let langle = self . consumePrefix ( " < " , as : . leftAngle)
469
469
var elements = [ RawGenericParameterSyntax] ( )
470
470
do {
471
471
var keepGoing : RawTokenSyntax ? = nil
@@ -477,7 +477,7 @@ extension Parser {
477
477
var each = self . consume ( if: . keyword( . each) )
478
478
479
479
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 : " > " ) {
481
481
break
482
482
}
483
483
Original file line number Diff line number Diff line change @@ -1066,7 +1066,7 @@ final class RecoveryTests: XCTestCase {
1066
1066
assertParse (
1067
1067
"""
1068
1068
// Note: Don't move braces to a different line here.
1069
- struct ErrorGenericParameterList4< 1️⃣
1069
+ struct ErrorGenericParameterList4<1️⃣
1070
1070
{
1071
1071
}
1072
1072
""" ,
@@ -2286,4 +2286,34 @@ final class RecoveryTests: XCTestCase {
2286
2286
)
2287
2287
}
2288
2288
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
+ }
2289
2319
}
You can’t perform that action at this time.
0 commit comments