From a6d97ecade1f572cb2d0c3bc61cb547074b849b9 Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Sat, 23 May 2020 05:40:36 +0900 Subject: [PATCH 1/2] [ConstraintSystem][NFC] rename `keyword_arguments.swift` to ... `argument_matching.swift` in test. New filename indicates that is also contains a test case for matching of unlabeled arguments. --- .../{keyword_arguments.swift => argument_matching.swift} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/Constraints/{keyword_arguments.swift => argument_matching.swift} (100%) diff --git a/test/Constraints/keyword_arguments.swift b/test/Constraints/argument_matching.swift similarity index 100% rename from test/Constraints/keyword_arguments.swift rename to test/Constraints/argument_matching.swift From 339f1797311bac77b6d29f9c3ecef7b8637fe13e Mon Sep 17 00:00:00 2001 From: omochimetaru Date: Sat, 23 May 2020 06:15:13 +0900 Subject: [PATCH 2/2] [ConstraintSystem][NFC] Move test cases about argument matching ... from `diagnostics.swift` to `argument_matching.swift` which has more specific interest. --- test/Constraints/argument_matching.swift | 161 ++++++++++++++++++++++ test/Constraints/diagnostics.swift | 162 ----------------------- 2 files changed, 161 insertions(+), 162 deletions(-) diff --git a/test/Constraints/argument_matching.swift b/test/Constraints/argument_matching.swift index 8ea73b96d2033..f93366259302a 100644 --- a/test/Constraints/argument_matching.swift +++ b/test/Constraints/argument_matching.swift @@ -66,6 +66,13 @@ class GenericCtor { } GenericCtor() // expected-error{{missing argument for parameter 't' in call}} +func secondArgumentNotLabeled(a: Int, _ b: Int) { } +secondArgumentNotLabeled(10, 20) +// expected-error@-1 {{missing argument label 'a:' in call}} + +func f_31849281(x: Int, y: Int, z: Int) {} +f_31849281(42, y: 10, x: 20) // expected-error {{incorrect argument labels in call (have '_:y:x:', expected 'x:y:z:')}} {{12-12=x: }} {{23-24=z}} + // ------------------------------------------- // Extraneous keywords // ------------------------------------------- @@ -82,12 +89,51 @@ somekeywords1(x: 1, y: 2, z: 3) // expected-error{{extraneous argument label 'x: somekeywords1(1, 2, 3) // expected-error{{missing argument labels 'y:z:' in call}}{{18-18=y: }}{{21-21=z: }} somekeywords1(x: 1, 2, z: 3) // expected-error{{incorrect argument labels in call (have 'x:_:z:', expected '_:y:z:')}}{{15-18=}}{{21-21=y: }} +// SR-2242: poor diagnostic when argument label is omitted + +func r27212391(x: Int, _ y: Int) { + let _: Int = x + y +} + +func r27212391(a: Int, x: Int, _ y: Int) { + let _: Int = a + x + y +} + +r27212391(3, 5) // expected-error {{missing argument label 'x:' in call}} +r27212391(3, y: 5) // expected-error {{incorrect argument labels in call (have '_:y:', expected 'x:_:')}} +r27212391(3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #1}} {{11-11=x: 5, }} {{12-18=}} +r27212391(y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'y:x:', expected 'x:_:')}} {{11-12=x}} {{17-20=}} +r27212391(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:_:', expected 'x:_:')}} +r27212391(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}} +r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}} +r27212391(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}} +r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}} +r27212391(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{17-17=x: 5, }} {{18-24=}} // ------------------------------------------- // Out-of-order keywords // ------------------------------------------- allkeywords1(y: 1, x: 2) // expected-error{{argument 'x' must precede argument 'y'}} {{14-14=x: 2, }} {{18-24=}} +// rdar://problem/31849281 - Let's play "bump the argument" + +struct rdar31849281 { var foo, a, b, c: Int } +_ = rdar31849281(a: 101, b: 102, c: 103, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} + +_ = rdar31849281(a: 101, c: 103, b: 102, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} +_ = rdar31849281(foo: 104, a: 101, c: 103, b: 102) // expected-error {{argument 'b' must precede argument 'c'}} {{36-36=b: 102, }} {{42-50=}} + +_ = rdar31849281(b: 102, c: 103, a: 101, foo: 104) // expected-error {{incorrect argument labels in call (have 'b:c:a:foo:', expected 'foo:a:b:c:')}} {{18-19=foo}} {{26-27=a}} {{34-35=b}} {{42-45=c}} +_ = rdar31849281(foo: 104, b: 102, c: 103, a: 101) // expected-error {{argument 'a' must precede argument 'b'}} {{28-28=a: 101, }} {{42-50=}} + +func fun_31849281(a: (Bool) -> Bool, b: (Int) -> (String), c: [Int?]) {} +fun_31849281(c: [nil, 42], a: { !$0 }, b: { (num: Int) -> String in return "\(num)" }) +// expected-error @-1 {{incorrect argument labels in call (have 'c:a:b:', expected 'a:b:c:')}} {{14-15=a}} {{28-29=b}} {{40-41=c}} +fun_31849281(a: { !$0 }, c: [nil, 42], b: { (num: Int) -> String in return String(describing: num) }) +// expected-error @-1 {{argument 'b' must precede argument 'c'}} {{26-26=b: { (num: Int) -> String in return String(describing: num) }, }} {{38-101=}} +fun_31849281(a: { !$0 }, c: [nil, 42], b: { "\($0)" }) +// expected-error @-1 {{argument 'b' must precede argument 'c'}} {{26-26=b: { "\\($0)" }, }} {{38-54=}} + // ------------------------------------------- // Default arguments // ------------------------------------------- @@ -127,6 +173,9 @@ defargs2(first: 1, z: 3, y: 2, last: 4) // expected-error{{argument 'y' must pre defargs2(x: 1, first: 1, last: 4) // expected-error{{argument 'first' must precede argument 'x'}} {{10-10=first: 1, }} {{14-24=}} defargs2(first: 1, last: 4, x: 1) // expected-error{{argument 'x' must precede argument 'last'}} {{20-20=x: 1, }} {{27-33=}} +func rdar43525641(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {} +rdar43525641(1, c: 2, 3) // Ok + // ------------------------------------------- // Variadics // ------------------------------------------- @@ -334,6 +383,9 @@ struct Variadics8 { } } +func var_31849281(_ a: Int, _ b: Int..., c: Int) {} +var_31849281(1, c: 10, 3, 4, 5, 6, 7, 8, 9) // expected-error {{unnamed argument #3 must precede argument 'c'}} {{17-17=3, 4, 5, 6, 7, 8, 9, }} {{22-43=}} + // ------------------------------------------- // Positions around defaults and variadics // ------------------------------------------- @@ -630,6 +682,18 @@ mismatch1(foo: 5) // expected-error {{extra argument 'foo' in call}} mismatch1(baz: 1, wobble: 2) // expected-error{{incorrect argument labels in call (have 'baz:wobble:', expected 'bar:wibble:')}} {{11-14=bar}} {{19-25=wibble}} mismatch1(food: 1, zap: 2) // expected-error{{extra arguments at positions #1, #2 in call}} +// QoI: FailureDiagnosis doesn't look through 'try' +struct rdar27891805 { + init(contentsOf: String, encoding: String) throws {} + init(contentsOf: String, usedEncoding: inout String) throws {} + init(_ t: T) {} +} + +try rdar27891805(contentsOfURL: nil, usedEncoding: nil) +// expected-error@-1 {{incorrect argument label in call (have 'contentsOfURL:usedEncoding:', expected 'contentsOf:usedEncoding:')}} +// expected-error@-2 {{'nil' is not compatible with expected argument type 'String'}} +// expected-error@-3 {{'nil' is not compatible with expected argument type 'String'}} + // ------------------------------------------- // Out of order and default // ------------------------------------------- @@ -874,3 +938,100 @@ func generic_and_missing_label(x: T) {} generic_and_missing_label(42) // expected-error@-1 {{missing argument label 'x:' in call}} {{27-27=x: }} + +// ------------------------------------------- +// Curried functions +// ------------------------------------------- + +func f7(_ a: Int) -> (_ b: Int) -> Int { + return { b in a+b } +} + +_ = f7(1)(1) +f7(1.0)(2) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} + +f7(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +f7(1)(b: 1.0) // expected-error{{extraneous argument label 'b:' in call}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} + +let f10 = f7(2) +_ = f10(1) +f10(10) // expected-warning {{result of call to function returning 'Int' is unused}} +f10(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +f10(b: 1.0) // expected-error {{extraneous argument label 'b:' in call}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} + + +class CurriedClass { + func method1() {} + func method2(_ a: Int) -> (_ b : Int) -> () { return { b in () } } + func method3(_ a: Int, b : Int) {} // expected-note 3 {{'method3(_:b:)' declared here}} +} + +let c = CurriedClass() +_ = c.method1 +c.method1(1) // expected-error {{argument passed to call that takes no arguments}} +_ = c.method2(1) +_ = c.method2(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +c.method2(1)(2) +c.method2(1)(c: 2) // expected-error {{extraneous argument label 'c:' in call}} +c.method2(1)(c: 2.0) // expected-error {{extraneous argument label 'c:' in call}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} +c.method2(1)(2.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +c.method2(1.0)(2) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +c.method2(1.0)(2.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} + +CurriedClass.method1(c)() +_ = CurriedClass.method1(c) +CurriedClass.method1(c)(1) // expected-error {{argument passed to call that takes no arguments}} +CurriedClass.method1(2.0)(1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'CurriedClass'}} +// expected-error@-1:27 {{argument passed to call that takes no arguments}} + +CurriedClass.method2(c)(32)(b: 1) // expected-error{{extraneous argument label 'b:' in call}} +_ = CurriedClass.method2(c) +_ = CurriedClass.method2(c)(32) +_ = CurriedClass.method2(1,2) // expected-error {{extra argument in call}} +// expected-error@-1 {{instance member 'method2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} +CurriedClass.method2(c)(1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +// expected-error@-1 {{extraneous argument label 'b:' in call}} +CurriedClass.method2(c)(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +CurriedClass.method2(c)(2)(c: 1.0) // expected-error {{extraneous argument label 'c:'}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} + +CurriedClass.method3(c)(32, b: 1) +_ = CurriedClass.method3(c) +_ = CurriedClass.method3(c)(1, 2) // expected-error {{missing argument label 'b:' in call}} {{32-32=b: }} +_ = CurriedClass.method3(c)(1, b: 2)(32) // expected-error {{cannot call value of non-function type '()'}} +_ = CurriedClass.method3(1, 2) // expected-error {{instance member 'method3' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} +// expected-error@-1 {{missing argument label 'b:' in call}} +CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} +CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}} +CurriedClass.method3(c)(c: 1.0) // expected-error {{incorrect argument labels in call (have 'c:', expected '_:b:')}} +// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} +// expected-error@-2 {{missing argument for parameter #1 in call}} + + +extension CurriedClass { + func f() { + method3(1, b: 2) + method3() // expected-error {{missing arguments for parameters #1, 'b' in call}} {{13-13=<#Int#>, b: <#Int#>}} + method3(42) // expected-error {{missing argument for parameter 'b' in call}} + method3(self) + // expected-error@-1:13 {{cannot convert value of type 'CurriedClass' to expected argument type 'Int'}} + // expected-error@-2:17 {{missing argument for parameter 'b' in call}} {{17-17=, b: <#Int#>}} + } +} + +extension CurriedClass { + func m1(_ a : Int, b : Int) {} + + func m2(_ a : Int) {} +} + +// QoI: "Extra argument" error when accidentally currying a method +CurriedClass.m1(2, b: 42) // expected-error {{instance member 'm1' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} + + +// QoI: Confusing error message when calling an instance method as a class method +CurriedClass.m2(12) // expected-error {{instance member 'm2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} diff --git a/test/Constraints/diagnostics.swift b/test/Constraints/diagnostics.swift index c10f96ad1e126..003387b8829e6 100644 --- a/test/Constraints/diagnostics.swift +++ b/test/Constraints/diagnostics.swift @@ -391,103 +391,6 @@ func rdar19804707() { _ = knownOps } - -func f7(_ a: Int) -> (_ b: Int) -> Int { - return { b in a+b } -} - -_ = f7(1)(1) -f7(1.0)(2) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} - -f7(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -f7(1)(b: 1.0) // expected-error{{extraneous argument label 'b:' in call}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} - -let f10 = f7(2) -_ = f10(1) -f10(10) // expected-warning {{result of call to function returning 'Int' is unused}} -f10(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -f10(b: 1.0) // expected-error {{extraneous argument label 'b:' in call}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} - - -class CurriedClass { - func method1() {} - func method2(_ a: Int) -> (_ b : Int) -> () { return { b in () } } - func method3(_ a: Int, b : Int) {} // expected-note 3 {{'method3(_:b:)' declared here}} -} - -let c = CurriedClass() -_ = c.method1 -c.method1(1) // expected-error {{argument passed to call that takes no arguments}} -_ = c.method2(1) -_ = c.method2(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -c.method2(1)(2) -c.method2(1)(c: 2) // expected-error {{extraneous argument label 'c:' in call}} -c.method2(1)(c: 2.0) // expected-error {{extraneous argument label 'c:' in call}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} -c.method2(1)(2.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -c.method2(1.0)(2) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -c.method2(1.0)(2.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} - -CurriedClass.method1(c)() -_ = CurriedClass.method1(c) -CurriedClass.method1(c)(1) // expected-error {{argument passed to call that takes no arguments}} -CurriedClass.method1(2.0)(1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'CurriedClass'}} -// expected-error@-1:27 {{argument passed to call that takes no arguments}} - -CurriedClass.method2(c)(32)(b: 1) // expected-error{{extraneous argument label 'b:' in call}} -_ = CurriedClass.method2(c) -_ = CurriedClass.method2(c)(32) -_ = CurriedClass.method2(1,2) // expected-error {{extra argument in call}} -// expected-error@-1 {{instance member 'method2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} -CurriedClass.method2(c)(1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -// expected-error@-1 {{extraneous argument label 'b:' in call}} -CurriedClass.method2(c)(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -CurriedClass.method2(c)(2)(c: 1.0) // expected-error {{extraneous argument label 'c:'}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} - -CurriedClass.method3(c)(32, b: 1) -_ = CurriedClass.method3(c) -_ = CurriedClass.method3(c)(1, 2) // expected-error {{missing argument label 'b:' in call}} {{32-32=b: }} -_ = CurriedClass.method3(c)(1, b: 2)(32) // expected-error {{cannot call value of non-function type '()'}} -_ = CurriedClass.method3(1, 2) // expected-error {{instance member 'method3' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} -// expected-error@-1 {{missing argument label 'b:' in call}} -CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}} -CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}} -CurriedClass.method3(c)(c: 1.0) // expected-error {{incorrect argument labels in call (have 'c:', expected '_:b:')}} -// expected-error@-1 {{cannot convert value of type 'Double' to expected argument type 'Int'}} -// expected-error@-2 {{missing argument for parameter #1 in call}} - - -extension CurriedClass { - func f() { - method3(1, b: 2) - method3() // expected-error {{missing arguments for parameters #1, 'b' in call}} {{13-13=<#Int#>, b: <#Int#>}} - method3(42) // expected-error {{missing argument for parameter 'b' in call}} - method3(self) - // expected-error@-1:13 {{cannot convert value of type 'CurriedClass' to expected argument type 'Int'}} - // expected-error@-2:17 {{missing argument for parameter 'b' in call}} {{17-17=, b: <#Int#>}} - } -} - -extension CurriedClass { - func m1(_ a : Int, b : Int) {} - - func m2(_ a : Int) {} -} - -// QoI: "Extra argument" error when accidentally currying a method -CurriedClass.m1(2, b: 42) // expected-error {{instance member 'm1' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} - - -// QoI: Confusing error message when calling an instance method as a class method -CurriedClass.m2(12) // expected-error {{instance member 'm2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}} - - - - // Error message does not tell me what the problem is enum Color { case Red @@ -847,10 +750,6 @@ func nilComparison(i: Int, o: AnyObject) { _ = o !== nil // expected-warning {{comparing non-optional value of type 'AnyObject' to 'nil' always returns true}} } -func secondArgumentNotLabeled(a: Int, _ b: Int) { } -secondArgumentNotLabeled(10, 20) -// expected-error@-1 {{missing argument label 'a:' in call}} - // QoI: incorrect ambiguity error due to implicit conversion func testImplConversion(a : Float?) -> Bool {} func testImplConversion(a : Int?) -> Bool { @@ -910,18 +809,6 @@ let sr1752: SR1752? true ? nil : sr1752?.foo() // don't generate a warning about unused result since foo returns Void -// QoI: FailureDiagnosis doesn't look through 'try' -struct rdar27891805 { - init(contentsOf: String, encoding: String) throws {} - init(contentsOf: String, usedEncoding: inout String) throws {} - init(_ t: T) {} -} - -try rdar27891805(contentsOfURL: nil, usedEncoding: nil) -// expected-error@-1 {{incorrect argument label in call (have 'contentsOfURL:usedEncoding:', expected 'contentsOf:usedEncoding:')}} -// expected-error@-2 {{'nil' is not compatible with expected argument type 'String'}} -// expected-error@-3 {{'nil' is not compatible with expected argument type 'String'}} - // Make sure RawRepresentable fix-its don't crash in the presence of type variables class NSCache { func object(forKey: K) -> V? {} @@ -937,27 +824,6 @@ func valueForKey(_ key: K) -> CacheValue? { return cache.object(forKey: key)?.value // expected-error {{no exact matches in reference to instance method 'value'}} } -// SR-2242: poor diagnostic when argument label is omitted - -func r27212391(x: Int, _ y: Int) { - let _: Int = x + y -} - -func r27212391(a: Int, x: Int, _ y: Int) { - let _: Int = a + x + y -} - -r27212391(3, 5) // expected-error {{missing argument label 'x:' in call}} -r27212391(3, y: 5) // expected-error {{incorrect argument labels in call (have '_:y:', expected 'x:_:')}} -r27212391(3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #1}} {{11-11=x: 5, }} {{12-18=}} -r27212391(y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'y:x:', expected 'x:_:')}} {{11-12=x}} {{17-20=}} -r27212391(y: 3, 5) // expected-error {{incorrect argument label in call (have 'y:_:', expected 'x:_:')}} -r27212391(x: 3, x: 5) // expected-error {{extraneous argument label 'x:' in call}} -r27212391(a: 1, 3, y: 5) // expected-error {{incorrect argument labels in call (have 'a:_:y:', expected 'a:x:_:')}} -r27212391(1, x: 3, y: 5) // expected-error {{incorrect argument labels in call (have '_:x:y:', expected 'a:x:_:')}} -r27212391(a: 1, y: 3, x: 5) // expected-error {{incorrect argument labels in call (have 'a:y:x:', expected 'a:x:_:')}} -r27212391(a: 1, 3, x: 5) // expected-error {{argument 'x' must precede unnamed argument #2}} {{17-17=x: 5, }} {{18-24=}} - // SR-1255 func foo1255_1() { return true || false @@ -1216,31 +1082,6 @@ class ListExpr_28456467 : AST_28456467, Expr_28456467 { } } -// rdar://problem/31849281 - Let's play "bump the argument" - -struct rdar31849281 { var foo, a, b, c: Int } -_ = rdar31849281(a: 101, b: 102, c: 103, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} - -_ = rdar31849281(a: 101, c: 103, b: 102, foo: 104) // expected-error {{argument 'foo' must precede argument 'a'}} {{18-18=foo: 104, }} {{40-50=}} -_ = rdar31849281(foo: 104, a: 101, c: 103, b: 102) // expected-error {{argument 'b' must precede argument 'c'}} {{36-36=b: 102, }} {{42-50=}} - -_ = rdar31849281(b: 102, c: 103, a: 101, foo: 104) // expected-error {{incorrect argument labels in call (have 'b:c:a:foo:', expected 'foo:a:b:c:')}} {{18-19=foo}} {{26-27=a}} {{34-35=b}} {{42-45=c}} -_ = rdar31849281(foo: 104, b: 102, c: 103, a: 101) // expected-error {{argument 'a' must precede argument 'b'}} {{28-28=a: 101, }} {{42-50=}} - -func var_31849281(_ a: Int, _ b: Int..., c: Int) {} -var_31849281(1, c: 10, 3, 4, 5, 6, 7, 8, 9) // expected-error {{unnamed argument #3 must precede argument 'c'}} {{17-17=3, 4, 5, 6, 7, 8, 9, }} {{22-43=}} - -func fun_31849281(a: (Bool) -> Bool, b: (Int) -> (String), c: [Int?]) {} -fun_31849281(c: [nil, 42], a: { !$0 }, b: { (num: Int) -> String in return "\(num)" }) -// expected-error @-1 {{incorrect argument labels in call (have 'c:a:b:', expected 'a:b:c:')}} {{14-15=a}} {{28-29=b}} {{40-41=c}} -fun_31849281(a: { !$0 }, c: [nil, 42], b: { (num: Int) -> String in return String(describing: num) }) -// expected-error @-1 {{argument 'b' must precede argument 'c'}} {{26-26=b: { (num: Int) -> String in return String(describing: num) }, }} {{38-101=}} -fun_31849281(a: { !$0 }, c: [nil, 42], b: { "\($0)" }) -// expected-error @-1 {{argument 'b' must precede argument 'c'}} {{26-26=b: { "\\($0)" }, }} {{38-54=}} - -func f_31849281(x: Int, y: Int, z: Int) {} -f_31849281(42, y: 10, x: 20) // expected-error {{incorrect argument labels in call (have '_:y:x:', expected 'x:y:z:')}} {{12-12=x: }} {{23-24=z}} - func sr5081() { var a = ["1", "2", "3", "4", "5"] var b = [String]() @@ -1286,9 +1127,6 @@ func unresolvedTypeExistential() -> Bool { // expected-error@-1 {{'_' can only appear in a pattern or on the left side of an assignment}} } -func rdar43525641(_ a: Int, _ b: Int = 0, c: Int = 0, _ d: Int) {} -rdar43525641(1, c: 2, 3) // Ok - do { struct Array {} let foo: Swift.Array = Array() // expected-error {{cannot convert value of type 'Array' to specified type 'Array'}}