Skip to content

Commit 13b4b03

Browse files
committed
Sema: Fix crash in IgnoreAssignmentDestinationType::diagnoseForAmbiguity()
1 parent 45ec809 commit 13b4b03

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/Sema/CSFix.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,15 +1796,18 @@ bool IgnoreAssignmentDestinationType::diagnoseForAmbiguity(
17961796
if (!overload)
17971797
return false;
17981798

1799-
auto memberName = overload->choice.getName().getBaseName();
1799+
auto declName = overload->choice.getName();
1800+
if (!declName)
1801+
return false;
1802+
18001803
auto destType = solution.getType(assignment->getDest());
18011804

18021805
auto &DE = cs.getASTContext().Diags;
18031806
// TODO(diagnostics): It might be good to add a tailored diagnostic
18041807
// for cases like this instead of using "contextual" one.
18051808
DE.diagnose(assignment->getSrc()->getLoc(),
18061809
diag::no_candidates_match_result_type,
1807-
memberName.userFacingName(),
1810+
declName.getBaseName().userFacingName(),
18081811
solution.simplifyType(destType)->getRValueType());
18091812

18101813
for (auto &entry : commonFixes) {

lib/Sema/ConstraintSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ DeclName OverloadChoice::getName() const {
20372037
case OverloadChoiceKind::MaterializePack:
20382038
case OverloadChoiceKind::TupleIndex:
20392039
case OverloadChoiceKind::ExtractFunctionIsolation:
2040-
llvm_unreachable("no name!");
2040+
return DeclName();
20412041
}
20422042

20432043
llvm_unreachable("Unhandled OverloadChoiceKind in switch.");
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// {"kind":"typecheck","original":"e0be092d","signature":"swift::constraints::IgnoreAssignmentDestinationType::diagnoseForAmbiguity(llvm::ArrayRef<std::__1::pair<swift::constraints::Solution const*, swift::constraints::ConstraintFix const*>>) const"}
2-
// RUN: not --crash %target-swift-frontend -typecheck %s
2+
// RUN: not %target-swift-frontend -typecheck %s
33
stride = (a:2).0

0 commit comments

Comments
 (0)