Skip to content

Commit 8e9556e

Browse files
committed
Constraint solver: use canBeArgumentLabel to determine when to quote a label.
Thanks to Chris for noticing this a few months back.
1 parent 81fc913 commit 8e9556e

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/Sema/CSApply.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/ASTVisitor.h"
2222
#include "swift/AST/ASTWalker.h"
2323
#include "swift/AST/Attr.h"
24+
#include "swift/Basic/StringExtras.h"
2425
#include "llvm/ADT/APFloat.h"
2526
#include "llvm/ADT/APInt.h"
2627
#include "llvm/ADT/SmallString.h"
@@ -5460,9 +5461,7 @@ diagnoseArgumentLabelError(Expr *expr, ArrayRef<Identifier> newNames,
54605461
continue;
54615462
}
54625463

5463-
tok newNameKind =
5464-
Lexer::kindOfIdentifier(newName.str(), /*inSILMode=*/false);
5465-
bool newNameIsReserved = newNameKind != tok::identifier;
5464+
bool newNameIsReserved = !canBeArgumentLabel(newName.str());
54665465
llvm::SmallString<16> newStr;
54675466
if (newNameIsReserved)
54685467
newStr += "`";

test/Constraints/keyword_arguments.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ allkeywords1(1, y: 2) // expected-error{{missing argument label 'x:' in call}} {
5151

5252
// If keyword is reserved, make sure to quote it. rdar://problem/21392294
5353
func reservedLabel(x: Int, `repeat`: Bool) {}
54-
reservedLabel(1, true) // expected-error{{missing argument label 'repeat:' in call}}{{18-18=`repeat`: }}
54+
reservedLabel(1, true) // expected-error{{missing argument label 'repeat:' in call}}{{18-18=repeat: }}
5555

5656
// Insert missing keyword before initial backtick. rdar://problem/21392294 part 2
5757
func reservedExpr(x: Int, y: Int) {}

0 commit comments

Comments
 (0)