Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -4008,10 +4008,13 @@ ERROR(throw_in_nonexhaustive_catch,none,
"error is not handled because the enclosing catch is not exhaustive", ())

ERROR(throwing_call_in_illegal_context,none,
"call can throw, but errors cannot be thrown out of %0",
(StringRef))
"call can throw, but errors cannot be thrown out of "
"%select{<<ERROR>>|a default argument|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factor out the %select into a #define maybe?

(unsigned))
ERROR(throw_in_illegal_context,none,
"errors cannot be thrown out of %0", (StringRef))
"errors cannot be thrown out of "
"%select{<<ERROR>>|a default argument|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}0",
(unsigned))

ERROR(throwing_operator_without_try,none,
"operator can throw but expression is not marked with 'try'", ())
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ add_swift_host_library(swiftSema STATIC
TypeCheckDeclObjC.cpp
TypeCheckDeclOverride.cpp
TypeCheckDeclPrimary.cpp
TypeCheckError.cpp
TypeCheckEffects.cpp
TypeCheckExpr.cpp
TypeCheckExprObjC.cpp
TypeCheckGeneric.cpp
Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/PCMacro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ class Instrumenter : InstrumenterBase {

if (NB != B) {
FD->setBody(NB);
TypeChecker::checkFunctionErrorHandling(FD);
TypeChecker::checkFunctionEffects(FD);
}
}
} else if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
Expand Down Expand Up @@ -695,7 +695,7 @@ void swift::performPCMacro(SourceFile &SF) {
BraceStmt *NewBody = I.transformBraceStmt(Body, true);
if (NewBody != Body) {
TLCD->setBody(NewBody);
TypeChecker::checkTopLevelErrorHandling(TLCD);
TypeChecker::checkTopLevelEffects(TLCD);
TypeChecker::contextualizeTopLevelCode(TLCD);
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions lib/Sema/PlaygroundTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ class Instrumenter : InstrumenterBase {
BraceStmt *NB = transformBraceStmt(B);
if (NB != B) {
FD->setBody(NB);
TypeChecker::checkFunctionErrorHandling(FD);
TypeChecker::checkFunctionEffects(FD);
}
}
} else if (auto *NTD = dyn_cast<NominalTypeDecl>(D)) {
Expand Down Expand Up @@ -893,7 +893,7 @@ void swift::performPlaygroundTransform(SourceFile &SF, bool HighPerformance) {
BraceStmt *NewBody = I.transformBraceStmt(Body);
if (NewBody != Body) {
FD->setBody(NewBody);
TypeChecker::checkFunctionErrorHandling(FD);
TypeChecker::checkFunctionEffects(FD);
}
return false;
}
Expand All @@ -905,7 +905,7 @@ void swift::performPlaygroundTransform(SourceFile &SF, bool HighPerformance) {
BraceStmt *NewBody = I.transformBraceStmt(Body, true);
if (NewBody != Body) {
TLCD->setBody(NewBody);
TypeChecker::checkTopLevelErrorHandling(TLCD);
TypeChecker::checkTopLevelEffects(TLCD);
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ EnumRawValuesRequest::evaluate(Evaluator &eval, EnumDecl *ED,
if (TypeChecker::typeCheckExpression(exprToCheck, ED,
rawTy,
CTP_EnumCaseRawValue)) {
TypeChecker::checkEnumElementErrorHandling(elt, exprToCheck);
TypeChecker::checkEnumElementEffects(elt, exprToCheck);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Sema/TypeCheckDeclPrimary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ Expr *DefaultArgumentExprRequest::evaluate(Evaluator &evaluator,
return new (ctx) ErrorExpr(initExpr->getSourceRange(), ErrorType::get(ctx));
}

TypeChecker::checkInitializerErrorHandling(dc, initExpr);
TypeChecker::checkInitializerEffects(dc, initExpr);

// Walk the checked initializer and contextualize any closures
// we saw there.
Expand Down Expand Up @@ -1657,7 +1657,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
PBD->getInitContext(i));
if (initContext) {
// Check safety of error-handling in the declaration, too.
TypeChecker::checkInitializerErrorHandling(initContext, init);
TypeChecker::checkInitializerEffects(initContext, init);
TypeChecker::contextualizeInitializer(initContext, init);
}
}
Expand Down
Loading