Skip to content

Commit 3d9b639

Browse files
authored
Merge pull request #24059 from sl/sl/sr-10293
Allow var / let as parameter names but provide a warning and fixit to add backticks.
2 parents ba0888d + ede8127 commit 3d9b639

File tree

15 files changed

+139
-76
lines changed

15 files changed

+139
-76
lines changed

include/swift/AST/DiagnosticsParse.def

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,9 @@ ERROR(parameter_specifier_as_attr_disallowed,none,
852852
"'%0' before a parameter name is not allowed, place it before the parameter type instead",
853853
(StringRef))
854854
ERROR(parameter_specifier_repeated,none,
855-
"parameter must not have multiple '__owned', 'inout', '__shared',"
856-
" 'var', or 'let' specifiers", ())
857-
ERROR(parameter_let_var_as_attr,none,
858-
"'%0' as a parameter attribute is not allowed",
855+
"parameter must not have multiple '__owned', 'inout', or '__shared' specifiers", ())
856+
WARNING(parameter_let_var_as_attr,none,
857+
"'%0' in this position is interpreted as an argument label",
859858
(StringRef))
860859

861860

include/swift/Parse/Parser.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,8 @@ class Parser {
609609

610610
void skipUntilDeclRBrace(tok T1, tok T2);
611611

612+
void skipListUntilDeclRBrace(SourceLoc startLoc, tok T1, tok T2);
613+
612614
/// Skip a single token, but match parentheses, braces, and square brackets.
613615
///
614616
/// Note: this does \em not match angle brackets ("<" and ">")! These are

include/swift/Parse/Token.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ class Token {
173173
return true;
174174
}
175175

176-
// 'let', 'var', and 'inout' cannot be argument labels.
177-
if (isAny(tok::kw_let, tok::kw_var, tok::kw_inout))
176+
// inout cannot be used as an argument label.
177+
if (is(tok::kw_inout))
178178
return false;
179179

180180
// All other keywords can be argument labels.

lib/Basic/StringExtras.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ using namespace camel_case;
3030

3131
bool swift::canBeArgumentLabel(StringRef identifier) {
3232
return llvm::StringSwitch<bool>(identifier)
33-
.Case("var", false)
34-
.Case("let", false)
3533
.Case("inout", false)
3634
.Case("$", false)
3735
.Default(true);

lib/Parse/ParsePattern.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
230230
}
231231
}
232232

233-
// ('inout' | 'let' | 'var' | '__shared' | '__owned')?
233+
// ('inout' | '__shared' | '__owned')?
234234
bool hasSpecifier = false;
235-
while (Tok.isAny(tok::kw_inout, tok::kw_let, tok::kw_var) ||
235+
while (Tok.is(tok::kw_inout) ||
236236
(Tok.is(tok::identifier) &&
237237
(Tok.getRawText().equals("__shared") ||
238238
Tok.getRawText().equals("__owned")))) {
@@ -254,10 +254,6 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
254254
// better fixits.
255255
param.SpecifierKind = VarDecl::Specifier::Owned;
256256
param.SpecifierLoc = consumeToken();
257-
} else {
258-
diagnose(Tok, diag::parameter_let_var_as_attr, Tok.getText())
259-
.fixItRemove(Tok.getLoc());
260-
consumeToken();
261257
}
262258
hasSpecifier = true;
263259
} else {
@@ -268,7 +264,14 @@ Parser::parseParameterClause(SourceLoc &leftParenLoc,
268264
consumeToken();
269265
}
270266
}
271-
267+
268+
// If let or var is being used as an argument label, allow it but
269+
// generate a warning.
270+
if (!isClosure && Tok.isAny(tok::kw_let, tok::kw_var)) {
271+
diagnose(Tok, diag::parameter_let_var_as_attr, Tok.getText())
272+
.fixItReplace(Tok.getLoc(), "`" + Tok.getText().str() + "`");
273+
}
274+
272275
if (startsParameterName(*this, isClosure)) {
273276
// identifier-or-none for the first name
274277
param.FirstNameLoc = consumeArgumentLabel(param.FirstName);

lib/Parse/Parser.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,39 @@ void Parser::skipUntilDeclStmtRBrace(tok T1, tok T2) {
741741
}
742742
}
743743

744+
void Parser::skipListUntilDeclRBrace(SourceLoc startLoc, tok T1, tok T2) {
745+
while (Tok.isNot(T1, T2, tok::eof, tok::r_brace, tok::pound_endif,
746+
tok::pound_else, tok::pound_elseif)) {
747+
bool hasDelimiter = Tok.getLoc() == startLoc || consumeIf(tok::comma);
748+
bool possibleDeclStartsLine = Tok.isAtStartOfLine();
749+
750+
if (isStartOfDecl()) {
751+
752+
// Could have encountered something like `_ var:`
753+
// or `let foo:` or `var:`
754+
if (Tok.isAny(tok::kw_var, tok::kw_let)) {
755+
if (possibleDeclStartsLine && !hasDelimiter) {
756+
break;
757+
}
758+
759+
Parser::BacktrackingScope backtrack(*this);
760+
// Consume the let or var
761+
consumeToken();
762+
763+
// If the following token is either <identifier> or :, it means that
764+
// this `var` or `let` shoud be interpreted as a label
765+
if ((Tok.canBeArgumentLabel() && peekToken().is(tok::colon)) ||
766+
peekToken().is(tok::colon)) {
767+
backtrack.cancelBacktrack();
768+
continue;
769+
}
770+
}
771+
break;
772+
}
773+
skipSingle();
774+
}
775+
}
776+
744777
void Parser::skipUntilDeclRBrace(tok T1, tok T2) {
745778
while (Tok.isNot(T1, T2, tok::eof, tok::r_brace, tok::pound_endif,
746779
tok::pound_else, tok::pound_elseif) &&
@@ -1006,7 +1039,7 @@ Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
10061039
// If we haven't made progress, or seeing any error, skip ahead.
10071040
if (Tok.getLoc() == StartLoc || Status.isError()) {
10081041
assert(Status.isError() && "no progress without error");
1009-
skipUntilDeclRBrace(RightK, tok::comma);
1042+
skipListUntilDeclRBrace(LeftLoc, RightK, tok::comma);
10101043
if (Tok.is(RightK) || Tok.isNot(tok::comma))
10111044
break;
10121045
}

test/IDE/complete_escaped_keyword.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ enum MyEnum {
2727
// STATIC_PRIMARY: Begin completion
2828
// STATIC_PRIMARY-DAG: Decl[LocalVar]/Local: self[#MyEnum.Type#]; name=self
2929
// STATIC_PRIMARY-DAG: Decl[EnumElement]/CurrNominal: `class`({#struct: String#})[#MyEnum#]; name=`class`(struct: String)
30-
// STATIC_PRIMARY-DAG: Decl[EnumElement]/CurrNominal: `let`({#`var`: String#})[#MyEnum#]; name=`let`(`var`: String)
30+
// STATIC_PRIMARY-DAG: Decl[EnumElement]/CurrNominal: `let`({#var: String#})[#MyEnum#]; name=`let`(var: String)
3131
// STATIC_PRIMARY-DAG: Decl[StaticMethod]/CurrNominal: `public`({#private: String#})[#Int#]; name=`public`(private: String)
3232
// STATIC_PRIMARY-DAG: Decl[InstanceMethod]/CurrNominal: `init`({#(self): MyEnum#})[#(deinit: String) -> Int#]; name=`init`(self: MyEnum)
3333
// STATIC_PRIMARY-DAG: Decl[InstanceMethod]/CurrNominal: `if`({#(self): MyEnum#})[#(else: String) -> Int#]; name=`if`(self: MyEnum)
@@ -37,7 +37,7 @@ enum MyEnum {
3737
// STATIC_SELF_NODOT: Begin completions
3838
// STATIC_SELF_NODOT-DAG: Keyword[self]/CurrNominal: .self[#MyEnum.Type#]; name=self
3939
// STATIC_SELF_NODOT-DAG: Decl[EnumElement]/CurrNominal: .class({#struct: String#})[#MyEnum#]; name=class(struct: String)
40-
// STATIC_SELF_NODOT-DAG: Decl[EnumElement]/CurrNominal: .let({#`var`: String#})[#MyEnum#]; name=let(`var`: String)
40+
// STATIC_SELF_NODOT-DAG: Decl[EnumElement]/CurrNominal: .let({#var: String#})[#MyEnum#]; name=let(var: String)
4141
// STATIC_SELF_NODOT-DAG: Decl[Constructor]/CurrNominal: .init({#init: String#})[#MyEnum#]; name=init(init: String)
4242
// STATIC_SELF_NODOT-DAG: Decl[StaticMethod]/CurrNominal: .public({#private: String#})[#Int#]; name=public(private: String)
4343
// STATIC_SELF_NODOT-DAG: Decl[InstanceMethod]/CurrNominal: .`init`({#(self): MyEnum#})[#(deinit: String) -> Int#]; name=`init`(self: MyEnum)
@@ -48,7 +48,7 @@ enum MyEnum {
4848
// STATIC_SELF_DOT: Begin completions
4949
// STATIC_SELF_DOT-DAG: Keyword[self]/CurrNominal: self[#MyEnum.Type#]; name=self
5050
// STATIC_SELF_DOT-DAG: Decl[EnumElement]/CurrNominal: class({#struct: String#})[#MyEnum#]; name=class(struct: String)
51-
// STATIC_SELF_DOT-DAG: Decl[EnumElement]/CurrNominal: let({#`var`: String#})[#MyEnum#]; name=let(`var`: String)
51+
// STATIC_SELF_DOT-DAG: Decl[EnumElement]/CurrNominal: let({#var: String#})[#MyEnum#]; name=let(var: String)
5252
// STATIC_SELF_DOT-DAG: Decl[Constructor]/CurrNominal: init({#init: String#})[#MyEnum#]; name=init(init: String)
5353
// STATIC_SELF_DOT-DAG: Decl[StaticMethod]/CurrNominal: public({#private: String#})[#Int#]; name=public(private: String)
5454
// STATIC_SELF_DOT-DAG: Decl[InstanceMethod]/CurrNominal: `init`({#(self): MyEnum#})[#(deinit: String) -> Int#]; name=`init`(self: MyEnum)

test/IDE/print_ast_tc_decls.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ struct d0200_EscapedIdentifiers {
622622
// PASS_COMMON-NEXT: {{^}} @_hasInitialValue var `var`: {{(d0200_EscapedIdentifiers.)?}}`struct`{{$}}
623623

624624
var tupleType: (`var`: Int, `let`: `struct`)
625-
// PASS_COMMON-NEXT: {{^}} var tupleType: (`var`: Int, `let`: {{(d0200_EscapedIdentifiers.)?}}`struct`){{$}}
625+
// PASS_COMMON-NEXT: {{^}} var tupleType: (var: Int, let: {{(d0200_EscapedIdentifiers.)?}}`struct`){{$}}
626626

627627
var accessors1: Int {
628628
get { return 0 }
@@ -633,7 +633,7 @@ struct d0200_EscapedIdentifiers {
633633
static func `static`(protocol: Int) {}
634634
// PASS_COMMON-NEXT: {{^}} static func `static`(protocol: Int){{$}}
635635

636-
// PASS_COMMON-NEXT: {{^}} init(`var`: {{(d0200_EscapedIdentifiers.)?}}`struct` = {{(d0200_EscapedIdentifiers.)?}}`struct`(), tupleType: (`var`: Int, `let`: {{(d0200_EscapedIdentifiers.)?}}`struct`)){{$}}
636+
// PASS_COMMON-NEXT: {{^}} init(var: {{(d0200_EscapedIdentifiers.)?}}`struct` = {{(d0200_EscapedIdentifiers.)?}}`struct`(), tupleType: (var: Int, let: {{(d0200_EscapedIdentifiers.)?}}`struct`)){{$}}
637637
// PASS_COMMON-NEXT: {{^}}}{{$}}
638638
}
639639

test/Parse/invalid.swift

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
// RUN: %target-typecheck-verify-swift
22

33
// rdar://15946844
4-
func test1(inout var x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{18-22=}}
4+
func test1(inout var x : Int) {} // expected-warning {{'var' in this position is interpreted as an argument label}} {{18-21=`var`}}
55
// expected-error @-1 {{'inout' before a parameter name is not allowed, place it before the parameter type instead}} {{12-17=}} {{26-26=inout }}
6-
func test2(inout let x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{18-22=}}
6+
func test2(inout let x : Int) {} // expected-warning {{'let' in this position is interpreted as an argument label}} {{18-21=`let`}}
77
// expected-error @-1 {{'inout' before a parameter name is not allowed, place it before the parameter type instead}} {{12-17=}} {{26-26=inout }}
88
func test3(f : (inout _ x : Int) -> Void) {} // expected-error {{'inout' before a parameter name is not allowed, place it before the parameter type instead}}
99

10-
func test1s(__shared var x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{22-26=}}
10+
func test1s(__shared var x : Int) {} // expected-warning {{'var' in this position is interpreted as an argument label}} {{22-25=`var`}}
1111
// expected-error @-1 {{'__shared' before a parameter name is not allowed, place it before the parameter type instead}} {{13-21=}} {{30-30=__shared }}
12-
func test2s(__shared let x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{22-26=}}
12+
func test2s(__shared let x : Int) {} // expected-warning {{'let' in this position is interpreted as an argument label}} {{22-25=`let`}}
1313
// expected-error @-1 {{'__shared' before a parameter name is not allowed, place it before the parameter type instead}} {{13-21=}} {{30-30=__shared }}
1414

15-
func test1o(__owned var x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{21-25=}}
15+
func test1o(__owned var x : Int) {} // expected-warning {{'var' in this position is interpreted as an argument label}} {{21-24=`var`}}
1616
// expected-error @-1 {{'__owned' before a parameter name is not allowed, place it before the parameter type instead}} {{13-20=}}
17-
func test2o(__owned let x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{21-25=}}
17+
func test2o(__owned let x : Int) {} // expected-warning {{'let' in this position is interpreted as an argument label}} {{21-24=`let`}}
1818
// expected-error @-1 {{'__owned' before a parameter name is not allowed, place it before the parameter type instead}} {{13-20=}}
1919

2020
func test3() {
@@ -84,27 +84,15 @@ func SR698(_ a: Int, b: Int) {}
8484
SR698(1, b: 2,) // expected-error {{unexpected ',' separator}}
8585

8686
// SR-979 - Two inout crash compiler
87-
func SR979a(a : inout inout Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{17-23=}}
87+
func SR979a(a : inout inout Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{17-23=}}
8888
func SR979b(inout inout b: Int) {} // expected-error {{inout' before a parameter name is not allowed, place it before the parameter type instead}} {{13-18=}} {{28-28=inout }}
89-
// expected-error@-1 {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{19-25=}}
90-
func SR979c(let a: inout Int) {} // expected-error {{'let' as a parameter attribute is not allowed}} {{13-16=}}
91-
func SR979d(let let a: Int) {} // expected-error {{'let' as a parameter attribute is not allowed}} {{13-16=}}
92-
// expected-error @-1 {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{17-21=}}
93-
func SR979e(inout x: inout String) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{13-18=}}
94-
func SR979f(var inout x : Int) { // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{17-23=}}
95-
// expected-error @-1 {{'var' as a parameter attribute is not allowed}}
96-
x += 10 // expected-error {{left side of mutating operator isn't mutable: 'x' is a 'let' constant}}
97-
}
98-
func SR979g(inout i: inout Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{13-18=}}
99-
func SR979h(let inout x : Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{17-23=}}
100-
// expected-error @-1 {{'let' as a parameter attribute is not allowed}}
101-
class VarTester {
102-
init(var a: Int, var b: Int) {} // expected-error {{'var' as a parameter attribute is not allowed}}
103-
// expected-error @-1 {{'var' as a parameter attribute is not allowed}}
104-
func x(var b: Int) { //expected-error {{'var' as a parameter attribute is not allowed}}
105-
b += 10 // expected-error {{left side of mutating operator isn't mutable: 'b' is a 'let' constant}}
106-
}
107-
}
89+
// expected-error@-1 {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{19-25=}}
90+
func SR979d(let let a: Int) {} // expected-warning {{'let' in this position is interpreted as an argument label}} {{13-16=`let`}}
91+
// expected-error @-1 {{expected ',' separator}} {{20-20=,}}
92+
// expected-error @-2 {{parameter requires an explicit type}}
93+
// expected-warning @-3 {{extraneous duplicate parameter name; 'let' already has an argument label}} {{13-17=}}
94+
func SR979e(inout x: inout String) {} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{13-18=}}
95+
func SR979g(inout i: inout Int) {} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{13-18=}}
10896

10997
func repeat() {}
11098
// expected-error @-1 {{keyword 'repeat' cannot be used as an identifier here}}

test/Sema/immutability.swift

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ func test_mutability() {
232232

233233
func test_arguments(_ a : Int,
234234
b : Int,
235-
let c : Int) { // expected-error {{'let' as a parameter attribute is not allowed}} {{21-25=}}
235+
let c : Int) { // expected-warning {{'let' in this position is interpreted as an argument label}} {{21-24=`let`}}
236236
var b = b
237237
a = 1 // expected-error {{cannot assign to value: 'a' is a 'let' constant}}
238238
b = 2 // ok.
@@ -354,7 +354,7 @@ protocol SubscriptNoGetter {
354354
subscript (i: Int) -> Int { get }
355355
}
356356

357-
func testSubscriptNoGetter(let iis: SubscriptNoGetter) { // expected-error {{'let' as a parameter attribute is not allowed}}{{28-31=}}
357+
func testSubscriptNoGetter(let iis: SubscriptNoGetter) { // expected-warning {{'let' in this position is interpreted as an argument label}}{{28-31=`let`}}
358358
var _: Int = iis[17]
359359
}
360360

@@ -367,24 +367,30 @@ func testSelectorStyleArguments1(_ x: Int, bar y: Int) {
367367
_ = y
368368
}
369369

370-
func testSelectorStyleArguments2(let x: Int, // expected-error {{'let' as a parameter attribute is not allowed}}{{34-37=}}
371-
let bar y: Int) { // expected-error {{'let' as a parameter attribute is not allowed}}{{34-38=}}
372-
373-
370+
func testSelectorStyleArguments2(let x: Int, // expected-warning {{'let' in this position is interpreted as an argument label}}{{34-37=`let`}}
371+
let bar y: Int) { // expected-warning {{'let' in this position is interpreted as an argument label}}{{34-37=`let`}}
372+
// expected-error @-1 {{expected ',' separator}}
373+
// expected-error @-2 {{parameter requires an explicit type}}
374374
}
375375
func testSelectorStyleArguments3(_ x: Int, bar y: Int) {
376376
++x // expected-error {{cannot pass immutable value to mutating operator: 'x' is a 'let' constant}}
377377
++y // expected-error {{cannot pass immutable value to mutating operator: 'y' is a 'let' constant}}
378378
}
379379

380-
func invalid_inout(inout var x : Int) { // expected-error {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}} {{26-30=}}
381-
// expected-error @-1 {{'inout' before a parameter name is not allowed, place it before the parameter type instead}}{{20-25=}}{{34-34=inout }}
380+
func invalid_inout(inout var x : Int) { // expected-warning {{'var' in this position is interpreted as an argument label}} {{26-29=`var`}}
381+
// expected-error @-1 {{'inout' before a parameter name is not allowed, place it before the parameter type instead}} {{20-25=}} {{34-34=inout }}
382382
}
383-
func invalid_var(var x: Int) { // expected-error {{'var' as a parameter attribute is not allowed}}
384-
383+
384+
class VarTester {
385+
init(var a: Int, var b: Int) {} // expected-warning {{'var' in this position is interpreted as an argument label}} {{8-11=`var`}}
386+
// expected-warning @-1 {{'var' in this position is interpreted as an argument label}} {{20-23=`var`}}
387+
func x(var b: Int) { //expected-warning {{'var' in this position is interpreted as an argument label}} {{10-13=`var`}}
388+
b += 10 // expected-error {{left side of mutating operator isn't mutable: 'b' is a 'let' constant}}
389+
}
385390
}
391+
386392
func takesClosure(_: (Int) -> Int) {
387-
takesClosure { (var d) in d } // expected-error {{'var' as a parameter attribute is not allowed}}
393+
takesClosure { (var d) in d } // expected-error {{closure cannot have keyword arguments}}
388394
}
389395

390396
func updateInt(_ x : inout Int) {}
@@ -501,9 +507,6 @@ struct StructWithDelegatingInit {
501507
init() { self.init(x: 0); self.x = 22 } // expected-error {{'let' property 'x' may not be initialized directly; use "self.init(...)" or "self = ..." instead}}
502508
}
503509

504-
func test_recovery_missing_name_2(let: Int) {} // expected-error {{'let' as a parameter attribute is not allowed}}{{35-38=}}
505-
// expected-error @-1 {{expected parameter name followed by ':'}}
506-
507510
// <rdar://problem/16792027> compiler infinite loops on a really really mutating function
508511
struct F { // expected-note 1 {{in declaration of 'F'}}
509512
mutating mutating mutating f() { // expected-error 2 {{duplicate modifier}} expected-note 2 {{modifier already specified here}} expected-error {{expected declaration}}

test/decl/class/override.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class H : G {
169169

170170
@objc func manyA(_: AnyObject, _: AnyObject) {}
171171
@objc func manyB(_ a: AnyObject, b: AnyObject) {}
172-
@objc func manyC(var a: AnyObject, // expected-error {{'var' as a parameter attribute is not allowed}}
173-
var b: AnyObject) {} // expected-error {{'var' as a parameter attribute is not allowed}}
172+
@objc func manyC(var a: AnyObject, // expected-warning {{'var' in this position is interpreted as an argument label}} {{20-23=`var`}}
173+
var b: AnyObject) {} // expected-warning {{'var' in this position is interpreted as an argument label}} {{20-23=`var`}}
174174

175175
@objc func result() -> AnyObject? { return nil }
176176
@objc func both(_ x: AnyObject) -> AnyObject? { return x }

0 commit comments

Comments
 (0)