File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ extension Parser {
31
31
self . missingToken ( . identifier, text: nil )
32
32
)
33
33
} else {
34
- return ( nil , self . consumeAnyToken ( ) )
34
+ return ( nil , self . consumeAnyToken ( remapping : . identifier ) )
35
35
}
36
36
}
37
37
}
Original file line number Diff line number Diff line change @@ -494,4 +494,30 @@ final class StatementTests: XCTestCase {
494
494
func testDefaultIdentIdentifierInReturnStmt( ) {
495
495
AssertParse ( " return FileManager.default " )
496
496
}
497
+
498
+ func testDefaultAsIdentifierInSubscript( ) {
499
+ AssertParse (
500
+ """
501
+ data[position, default: 0]
502
+ """ ,
503
+ substructure: Syntax ( ExprSyntax ( SubscriptExprSyntax (
504
+ calledExpression: ExprSyntax ( IdentifierExprSyntax ( identifier: . identifier( " data " ) , declNameArguments: nil ) ) ,
505
+ leftBracket: . leftSquareBracketToken( ) ,
506
+ argumentList: TupleExprElementListSyntax ( [
507
+ TupleExprElementSyntax (
508
+ label: nil ,
509
+ colon: nil ,
510
+ expression: ExprSyntax ( IdentifierExprSyntax ( identifier: . identifier( " position " ) , declNameArguments: nil ) ) ,
511
+ trailingComma: . commaToken( ) ) ,
512
+ TupleExprElementSyntax (
513
+ label: . identifier( " default " ) ,
514
+ colon: . colonToken( ) ,
515
+ expression: ExprSyntax ( IntegerLiteralExprSyntax ( 0 ) ) ,
516
+ trailingComma: nil ) ,
517
+ ] ) ,
518
+ rightBracket: . rightSquareBracketToken( ) ,
519
+ trailingClosure: nil ,
520
+ additionalTrailingClosures: nil ) ) )
521
+ )
522
+ }
497
523
}
You can’t perform that action at this time.
0 commit comments