Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Sources/SwiftParser/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -944,13 +944,13 @@ extension Parser.Lookahead {
// by a type annotation.
if self.startsParameterName(isClosure: false, allowMisplacedSpecifierRecovery: false) {
self.consumeAnyToken()
// If we have a secondary argument label, consume it.
if self.atArgumentLabel() {
self.consumeAnyToken()
guard self.at(.colon) else {
return false
}
}
self.eat(.colon)
guard self.consume(if: .colon) != nil else {
return false
}

// Parse a type.
guard self.canParseType() else {
Expand Down
20 changes: 20 additions & 0 deletions Tests/SwiftParserTest/ExpressionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2145,6 +2145,26 @@ final class ExpressionTests: ParserTestCase {
"""
)
}

func testSecondaryArgumentLabelDollarIdentifierInClosure() {
assertParse(
"""
ℹ️{ a1️⃣: (a $
""",
diagnostics: [
DiagnosticSpec(
message: "expected '}' to end closure",
notes: [NoteSpec(message: "to match this opening '{'")],
fixIts: ["insert '}'"]
),
DiagnosticSpec(message: "extraneous code ': (a $' at top level"),
],
fixedSource: """
{ a
}: (a $
"""
)
}
}

final class MemberExprTests: ParserTestCase {
Expand Down
Loading