Skip to content

#keyPath Expressions Don't Actually Allow Compound Names #728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2022
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
5 changes: 3 additions & 2 deletions Sources/SwiftParser/Expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1282,11 +1282,12 @@ extension Parser {
// Parse the sequence of unqualified-names.
var elements = [RawObjcNamePieceSyntax]()
do {
var flags: DeclNameOptions = .compoundNames
var flags: DeclNameOptions = []
var keepGoing: RawTokenSyntax? = nil
repeat {
// Parse the next name.
let (name, _) = self.parseDeclNameRef(flags)
let (name, args) = self.parseDeclNameRef(flags)
assert(args == nil, "Found arguments but did not pass argument flag?")

// After the first component, we can start parsing keywords.
flags.formUnion(.keywords)
Expand Down
6 changes: 6 additions & 0 deletions Tests/SwiftParserTest/Expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,12 @@ final class ExpressionTests: XCTestCase {
DiagnosticSpec(message: "Expected '}' to end function"),
]
)

AssertParse("#keyPath(#^DIAG^#(b:)",
diagnostics: [
DiagnosticSpec(message: "Expected '' in '#keyPath' expression"),
DiagnosticSpec(message: "Expected ')' to end '#keyPath' expression"),
])
}

func testMissingArrowInArrowExpr() {
Expand Down