Skip to content

Commit 2704dbe

Browse files
committed
Sema: Fix crash on invalid code in diagnoseDictionaryLiteralDuplicateKeyEntries()
1 parent bd38456 commit 2704dbe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Sema/MiscDiagnostics.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6268,9 +6268,9 @@ diagnoseDictionaryLiteralDuplicateKeyEntries(const Expr *E,
62686268
note.fixItRemove(duplicated.first->getSourceRange());
62696269
if (duplicatedEltIdx < commanLocs.size()) {
62706270
note.fixItRemove(commanLocs[duplicatedEltIdx]);
6271-
} else {
6271+
} else if (!commanLocs.empty()) {
62726272
// For the last element remove the previous comma.
6273-
note.fixItRemove(commanLocs[duplicatedEltIdx - 1]);
6273+
note.fixItRemove(commanLocs[commanLocs.size() - 1]);
62746274
}
62756275
};
62766276

0 commit comments

Comments
 (0)