[CS] Fix a couple of missing error paths

Make sure we set `hadError` other we'll fail to invalidate the target.
This commit is contained in:
Hamish Knight
2025-11-14 14:13:23 +00:00
parent 7e95f8b614
commit 3f4c3b542f
3 changed files with 8 additions and 3 deletions

View File

@@ -2212,6 +2212,8 @@ private:
if (auto newResultTarget = rewriter.rewriteTarget(target)) {
resultExpr = newResultTarget->getAsExpr();
} else {
hadError = true;
}
switch (mode) {
@@ -2259,8 +2261,11 @@ private:
}
auto *resultExpr = thenStmt->getResult();
if (auto newResultTarget = rewriter.rewriteTarget(*target))
if (auto newResultTarget = rewriter.rewriteTarget(*target)) {
resultExpr = newResultTarget->getAsExpr();
} else {
hadError = true;
}
thenStmt->setResult(resultExpr);

View File

@@ -1,5 +1,5 @@
// {"kind":"typecheck","original":"7f0c85e8","signature":"diagSyntacticUseRestrictions(swift::Expr const*, swift::DeclContext const*, bool)::DiagnoseWalker::walkToExprPre(swift::Expr*)","signatureAssert":"Assertion failed: (Ptr && \"Cannot dereference a null Type!\"), function operator->"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
class a<b, c>: ExpressibleByDictionaryLiteral {
typealias Key = b
typealias Value = c

View File

@@ -1,5 +1,5 @@
// {"kind":"typecheck","signature":"(anonymous namespace)::ImplicitSelfUsageChecker::isClosureRequiringSelfQualification(swift::AbstractClosureExpr const*, bool)","signatureAssert":"Assertion failed: (Ptr && \"Cannot dereference a null Type!\"), function operator->"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
struct a : ExpressibleByBooleanLiteral {
c(d : Bool -> (
}