Skip to content

Commit 5729d2f

Browse files
authored
Merge pull request #32361 from theblixguy/fix/SR-12990-5.3
[5.3] [CS] Fix a crash in AllowArgumentMismatch
2 parents 6c1acb9 + edec4aa commit 5729d2f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,6 +3334,13 @@ void constraints::simplifyLocator(Expr *&anchor,
33343334
if (auto subscriptExpr = dyn_cast<SubscriptExpr>(anchor)) {
33353335
anchor = subscriptExpr->getIndex();
33363336
path = path.slice(1);
3337+
3338+
// TODO: It would be better if the index expression was always wrapped
3339+
// in a ParenExpr (if there is no label).
3340+
if (!(isa<TupleExpr>(anchor) || isa<ParenExpr>(anchor)) &&
3341+
!path.empty() && path[0].is<LocatorPathElt::ApplyArgToParam>()) {
3342+
path = path.slice(1);
3343+
}
33373344
continue;
33383345
}
33393346

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-swift-frontend -typecheck %s -verify
2+
3+
class ContainerTransition {
4+
var viewControllers: [Int: String]?
5+
func completeTransition() {
6+
viewControllers?[Int//.max
7+
// expected-error@-1 {{no exact matches in call to subscript}}
8+
// expected-note@-2 {{found candidate with type '((Int).Type) -> Dictionary<Int, String>.SubSequence' (aka '(Int.Type) -> Slice<Dictionary<Int, String>>')}}
9+
// expected-note@-3 {{to match this opening '['}}
10+
} // expected-error {{expected ']' in expression list}}
11+
}

0 commit comments

Comments
 (0)