File tree Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Expand file tree Collapse file tree 2 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -3976,17 +3976,14 @@ bool MissingMemberFailure::diagnoseInLiteralCollectionContext() const {
39763976 if (!parentExpr)
39773977 return false ;
39783978
3979- auto parentType = getType (parentExpr);
3979+ // This could happen if collection is a dictionary literal i.e.
3980+ // ["a": .test] - the element is a tuple - ("a", .test).
3981+ if (isExpr<TupleExpr>(parentExpr))
3982+ parentExpr = findParentExpr (parentExpr);
39803983
3981- if (!parentType-> isKnownStdlibCollectionType () && !parentType-> is <TupleType>( ))
3984+ if (!isExpr<CollectionExpr>(parentExpr ))
39823985 return false ;
39833986
3984- if (isa<TupleExpr>(parentExpr)) {
3985- parentExpr = findParentExpr (parentExpr);
3986- if (!parentExpr)
3987- return false ;
3988- }
3989-
39903987 if (auto *defaultableVar =
39913988 getRawType (parentExpr)->getAs <TypeVariableType>()) {
39923989 if (solution.DefaultedConstraints .count (
Original file line number Diff line number Diff line change @@ -546,3 +546,23 @@ func test_conflicting_pattern_vars() {
546546 }
547547 }
548548}
549+
550+ // rdar://91452726 - crash in MissingMemberFailure::diagnoseInLiteralCollectionContext
551+ struct Test {
552+ struct ID {
553+ }
554+
555+ enum E : Hashable , Equatable {
556+ case id
557+ }
558+
559+ var arr : [ ( ID , E ) ]
560+
561+ func test( ) {
562+ _ = arr. map { v in
563+ switch v {
564+ case . id: return true // expected-error {{value of tuple type '(Test.ID, Test.E)' has no member 'id'}}
565+ }
566+ }
567+ }
568+ }
You can’t perform that action at this time.
0 commit comments