Skip to content

Commit 5707ce3

Browse files
authored
Merge pull request #728 from CodaFi/a-pattern-of-behavior
#keyPath Expressions Don't Actually Allow Compound Names
2 parents 745922f + 3132c32 commit 5707ce3

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/SwiftParser/Expressions.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,12 +1284,13 @@ extension Parser {
12841284
// Parse the sequence of unqualified-names.
12851285
var elements = [RawObjcNamePieceSyntax]()
12861286
do {
1287-
var flags: DeclNameOptions = .compoundNames
1287+
var flags: DeclNameOptions = []
12881288
var keepGoing: RawTokenSyntax? = nil
12891289
var loopProgress = LoopProgressCondition()
12901290
repeat {
12911291
// Parse the next name.
1292-
let (name, _) = self.parseDeclNameRef(flags)
1292+
let (name, args) = self.parseDeclNameRef(flags)
1293+
assert(args == nil, "Found arguments but did not pass argument flag?")
12931294

12941295
// After the first component, we can start parsing keywords.
12951296
flags.formUnion(.keywords)

Tests/SwiftParserTest/Expressions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,12 @@ final class ExpressionTests: XCTestCase {
412412
DiagnosticSpec(message: "Expected '}' to end function"),
413413
]
414414
)
415+
416+
AssertParse("#keyPath(#^DIAG^#(b:)",
417+
diagnostics: [
418+
DiagnosticSpec(message: "Expected '' in '#keyPath' expression"),
419+
DiagnosticSpec(message: "Expected ')' to end '#keyPath' expression"),
420+
])
415421
}
416422

417423
func testMissingArrowInArrowExpr() {

0 commit comments

Comments
 (0)