Skip to content

Commit 673ccd1

Browse files
committed
[astgen] Fix argument/param labels/names.
1 parent cae1a2b commit 673ccd1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/ASTGen/Sources/ASTGen/Decls.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ extension ASTGenVisitor {
9191
let secondName: UnsafeMutableRawPointer?
9292
let type: UnsafeMutableRawPointer?
9393

94-
if let nodeFirstName = node.firstName {
94+
if let nodeFirstName = node.firstName,
95+
// Swift AST represnts "_" as nil.
96+
nodeFirstName.text != "_" {
9597
var text = nodeFirstName.text
9698
firstName = text.withUTF8 { buf in
9799
SwiftASTContext_getIdentifier(ctx, buf.baseAddress, buf.count)

lib/ASTGen/Sources/ASTGen/Exprs.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ extension ASTGenVisitor {
6464

6565
public func visit(_ node: TupleExprElementListSyntax) -> ASTNode {
6666
let elements = node.map { self.visit($0).rawValue }
67-
let labels: [BridgedIdentifier] = node.enumerated().map { (idx, e) in
68-
var name = e.label?.text ?? "\(idx)"
67+
let labels: [BridgedIdentifier?] = node.map {
68+
guard var name = $0.label?.text else {
69+
return nil
70+
}
6971
return name.withUTF8 { buf in
7072
SwiftASTContext_getIdentifier(ctx, buf.baseAddress, buf.count)
7173
}

0 commit comments

Comments
 (0)