Skip to content

Commit b96eef8

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 81ad405 + 558a318 commit b96eef8

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3045,15 +3045,20 @@ Type TypeResolver::resolveTupleType(TupleTypeRepr *repr,
30453045
complained = true;
30463046
}
30473047

3048+
bool hadError = false;
30483049
for (unsigned i = 0, end = repr->getNumElements(); i != end; ++i) {
30493050
auto *tyR = repr->getElementType(i);
30503051

30513052
Type ty = resolveType(tyR, elementOptions);
3052-
if (!ty || ty->hasError()) return ty;
3053+
if (!ty || ty->hasError())
3054+
hadError = true;
30533055

30543056
elements.emplace_back(ty, repr->getElementName(i), ParameterTypeFlags());
30553057
}
30563058

3059+
if (hadError)
3060+
return ErrorType::get(Context);
3061+
30573062
// Single-element labeled tuples are not permitted outside of declarations
30583063
// or SIL, either.
30593064
if (elements.size() == 1 && elements[0].hasName()

test/Compatibility/tuple_arguments_4.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,14 +1464,17 @@ let _ = sr4745.enumerated().map { (count, element) in "\(count): \(element)" }
14641464
// SR-4738
14651465

14661466
let sr4738 = (1, (2, 3))
1467-
[sr4738].map { (x, (y, z)) -> Int in x + y + z } // expected-error {{use of undeclared type 'y'}}
1467+
// expected-error @+2{{use of undeclared type 'y'}}
1468+
// expected-error @+1{{use of undeclared type 'z'}}
1469+
[sr4738].map { (x, (y, z)) -> Int in x + y + z }
14681470
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{20-26=arg1}} {{38-38=let (y, z) = arg1; }}
14691471

14701472
// rdar://problem/31892961
14711473
let r31892961_1 = [1: 1, 2: 2]
14721474
r31892961_1.forEach { (k, v) in print(k + v) }
14731475

14741476
let r31892961_2 = [1, 2, 3]
1477+
// expected-error @+1{{use of undeclared type 'val'}}
14751478
let _: [Int] = r31892961_2.enumerated().map { ((index, val)) in
14761479
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{48-60=arg0}} {{3-3=\n let (index, val) = arg0\n }}
14771480
// expected-error@-2 {{use of undeclared type 'index'}}
@@ -1689,4 +1692,4 @@ _ = x.map { (_: Void) in return () }
16891692
do {
16901693
func f(_: Int...) {}
16911694
let _ = [(1, 2, 3)].map(f) // expected-error {{cannot invoke 'map' with an argument list of type '((Int...) -> ())'}}
1692-
}
1695+
}

test/Constraints/tuple_arguments.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,14 +1467,17 @@ let _ = sr4745.enumerated().map { (count, element) in "\(count): \(element)" }
14671467
// SR-4738
14681468

14691469
let sr4738 = (1, (2, 3))
1470-
[sr4738].map { (x, (y, z)) -> Int in x + y + z } // expected-error {{use of undeclared type 'y'}}
1470+
// expected-error@+2{{use of undeclared type 'y'}}
1471+
// expected-error@+1{{use of undeclared type 'z'}}
1472+
[sr4738].map { (x, (y, z)) -> Int in x + y + z }
14711473
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{20-26=arg1}} {{38-38=let (y, z) = arg1; }}
14721474

14731475
// rdar://problem/31892961
14741476
let r31892961_1 = [1: 1, 2: 2]
14751477
r31892961_1.forEach { (k, v) in print(k + v) }
14761478

14771479
let r31892961_2 = [1, 2, 3]
1480+
// expected-error@+1{{use of undeclared type 'val'}}
14781481
let _: [Int] = r31892961_2.enumerated().map { ((index, val)) in
14791482
// expected-error@-1 {{closure tuple parameter does not support destructuring}} {{48-60=arg0}} {{3-3=\n let (index, val) = arg0\n }}
14801483
// expected-error@-2 {{use of undeclared type 'index'}}

test/attr/attr_inout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ func f(x : inout Int) { } // okay
44

55
func h(_ : inout Int) -> (inout Int) -> (inout Int) -> Int { }
66

7-
func ff(x: (inout Int, inout Float)) { } // expected-error {{'inout' may only be used on parameters}}
7+
func ff(x: (inout Int, inout Float)) { } // expected-error 2{{'inout' may only be used on parameters}}
88

99
enum inout_carrier {
1010
case carry(inout Int) // expected-error {{'inout' may only be used on parameters}}

test/decl/func/functions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func parseError6(_ a: unknown_type, b: ) {} // expected-error {{use of undeclare
8888

8989
func parseError7(_ a: Int, goo b: unknown_type) {} // expected-error {{use of undeclared type 'unknown_type'}}
9090

91-
public func foo(_ a: Bool = true) -> (b: Bar, c: Bar) {} // expected-error {{use of undeclared type 'Bar'}}
91+
public func foo(_ a: Bool = true) -> (b: Bar, c: Bar) {} // expected-error 2{{use of undeclared type 'Bar'}}
9292

9393
func parenPatternInArg((a): Int) -> Int { // expected-error {{expected parameter name followed by ':'}}
9494
return a // expected-error {{use of unresolved identifier 'a'}}

0 commit comments

Comments
 (0)