Skip to content

Commit 5c46ed0

Browse files
committed
[IDE] Fix assertion hit when a function call has no argument labels.
rdar://27611931.
1 parent 05d4951 commit 5c46ed0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/AST/SourceEntityWalker.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,13 @@ bool SemaAnnotator::passCallArgNames(Expr *Fn, TupleExpr *TupleE) {
426426

427427
ArrayRef<Identifier> ArgNames = TupleE->getElementNames();
428428
ArrayRef<SourceLoc> ArgLocs = TupleE->getElementNameLocs();
429-
assert(ArgNames.size() == ArgLocs.size());
430429
for (auto i : indices(ArgNames)) {
431430
Identifier Name = ArgNames[i];
431+
if (Name.empty())
432+
continue;
433+
432434
SourceLoc Loc = ArgLocs[i];
433-
if (Name.empty() || Loc.isInvalid())
435+
if (Loc.isInvalid())
434436
continue;
435437

436438
CharSourceRange Range{ Loc, Name.getLength() };

test/IDE/annotation.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,16 @@ func test_defer() {
328328
test_defer()
329329
}
330330
}
331+
332+
func test_arg_tuple1(_: Int, _: Int) {}
333+
func test_arg_tuple2(p1: Int, _: Int) {}
334+
func test_arg_tuple3(_: Int, p2: Int) {}
335+
func test_arg_tuple4(p1: Int, p2: Int) {}
336+
// CHECK: <Func@[[@LINE-4]]:6>test_arg_tuple1</Func>(0,0)
337+
test_arg_tuple1(0,0)
338+
// CHECK: <Func@[[@LINE-5]]:6>test_arg_tuple2</Func>(<Func@[[@LINE-5]]:6#p1>p1</Func>:0,0)
339+
test_arg_tuple2(p1:0,0)
340+
// CHECK: <Func@[[@LINE-6]]:6>test_arg_tuple3</Func>(0,<Func@[[@LINE-6]]:6#p2>p2</Func>:0)
341+
test_arg_tuple3(0,p2:0)
342+
// CHECK: <Func@[[@LINE-7]]:6>test_arg_tuple4</Func>(<Func@[[@LINE-7]]:6#p1>p1</Func>:0,<Func@[[@LINE-7]]:6#p2>p2</Func>:0)
343+
test_arg_tuple4(p1:0,p2:0)

0 commit comments

Comments
 (0)