File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -944,13 +944,13 @@ extension Parser.Lookahead {
944
944
// by a type annotation.
945
945
if self . startsParameterName ( isClosure: false , allowMisplacedSpecifierRecovery: false ) {
946
946
self . consumeAnyToken ( )
947
+ // If we have a secondary argument label, consume it.
947
948
if self . atArgumentLabel ( ) {
948
949
self . consumeAnyToken ( )
949
- guard self . at ( . colon) else {
950
- return false
951
- }
952
950
}
953
- self . eat ( . colon)
951
+ guard self . consume ( if: . colon) != nil else {
952
+ return false
953
+ }
954
954
955
955
// Parse a type.
956
956
guard self . canParseType ( ) else {
Original file line number Diff line number Diff line change @@ -2145,6 +2145,26 @@ final class ExpressionTests: ParserTestCase {
2145
2145
"""
2146
2146
)
2147
2147
}
2148
+
2149
+ func testSecondaryArgumentLabelDollarIdentifierInClosure( ) {
2150
+ assertParse (
2151
+ """
2152
+ ℹ️{ a1️⃣: (a $
2153
+ """ ,
2154
+ diagnostics: [
2155
+ DiagnosticSpec (
2156
+ message: " expected '}' to end closure " ,
2157
+ notes: [ NoteSpec ( message: " to match this opening '{' " ) ] ,
2158
+ fixIts: [ " insert '}' " ]
2159
+ ) ,
2160
+ DiagnosticSpec ( message: " extraneous code ': (a $' at top level " ) ,
2161
+ ] ,
2162
+ fixedSource: """
2163
+ { a
2164
+ }: (a $
2165
+ """
2166
+ )
2167
+ }
2148
2168
}
2149
2169
2150
2170
final class MemberExprTests : ParserTestCase {
You can’t perform that action at this time.
0 commit comments