Skip to content

Commit 9a28d02

Browse files
committed
Fix handling inline variable declaration lists.
1 parent 2d109e5 commit 9a28d02

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/SwiftLexicalLookup/LookupName.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ import SwiftSyntax
132132
switch Syntax(syntax).as(SyntaxEnum.self) {
133133
case .variableDecl(let variableDecl):
134134
variableDecl.bindings.flatMap { binding in
135-
getNames(from: binding.pattern, accessibleAfter: accessibleAfter)
135+
getNames(from: binding.pattern, accessibleAfter: accessibleAfter != nil ? binding.endPositionBeforeTrailingTrivia : nil)
136136
}
137137
case .tuplePattern(let tuplePattern):
138138
tuplePattern.elements.flatMap { tupleElement in

Tests/SwiftLexicalLookupTest/NameLookupTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class testNameLookup: XCTestCase {
5050
source: """
5151
for i in 1..<4 {
5252
let (1️⃣a, 2️⃣b) = (1, 2)
53-
let 3️⃣c = 3, 4️⃣d = 4
53+
let 3️⃣c = 3, 4️⃣d = 9️⃣c
5454
5555
5️⃣a
5656
6️⃣b
@@ -63,6 +63,7 @@ final class testNameLookup: XCTestCase {
6363
"6️⃣": [.fromScope(CodeBlockSyntax.self, expectedNames: ["2️⃣"])],
6464
"7️⃣": [.fromScope(CodeBlockSyntax.self, expectedNames: ["3️⃣"])],
6565
"8️⃣": [.fromScope(CodeBlockSyntax.self, expectedNames: ["4️⃣"])],
66+
"9️⃣": [.fromScope(CodeBlockSyntax.self, expectedNames: ["3️⃣"])],
6667
],
6768
expectedResultTypes: .all(IdentifierPatternSyntax.self)
6869
)

0 commit comments

Comments
 (0)