mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Diagnostics] Add a tailored fix when ternary is associated with return
If it has been detected that there is an attempt to return a value from a function without result type, let's diagnose that specifically in cases when ternary operator is involved.
This commit is contained in:
@@ -4224,6 +4224,12 @@ bool ConstraintSystem::repairFailures(
|
||||
if (hasFixFor(loc, FixKind::ContextualMismatch))
|
||||
return true;
|
||||
|
||||
if (contextualType->isVoid() &&
|
||||
getContextualTypePurpose(anchor) == CTP_ReturnStmt) {
|
||||
conversionsOrFixes.push_back(RemoveReturn::create(*this, lhs, loc));
|
||||
break;
|
||||
}
|
||||
|
||||
conversionsOrFixes.push_back(
|
||||
ContextualMismatch::create(*this, lhs, rhs, loc));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user