mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Don't ignore implicit AST nodes in diagnoseUnhandledThrowSite (#61392)
This commit is contained in:
@@ -4043,10 +4043,10 @@ generateForEachStmtConstraints(
|
||||
// `.next()`. `next()` is called on each iteration of the loop.
|
||||
{
|
||||
auto *nextRef = UnresolvedDotExpr::createImplicit(
|
||||
ctx,
|
||||
new (ctx) DeclRefExpr(makeIteratorVar, DeclNameLoc(),
|
||||
/*Implicit=*/true),
|
||||
ctx.Id_next, /*labels=*/ArrayRef<Identifier>());
|
||||
ctx,
|
||||
new (ctx) DeclRefExpr(makeIteratorVar, DeclNameLoc(stmt->getForLoc()),
|
||||
/*Implicit=*/true),
|
||||
ctx.Id_next, /*labels=*/ArrayRef<Identifier>());
|
||||
nextRef->setFunctionRefKind(FunctionRefKind::SingleApply);
|
||||
|
||||
Expr *nextCall = CallExpr::createImplicitEmpty(ctx, nextRef);
|
||||
|
||||
@@ -1775,9 +1775,6 @@ public:
|
||||
void diagnoseUnhandledThrowSite(DiagnosticEngine &Diags, ASTNode E,
|
||||
bool isTryCovered,
|
||||
const PotentialEffectReason &reason) {
|
||||
if (E.isImplicit())
|
||||
return;
|
||||
|
||||
switch (getKind()) {
|
||||
case Kind::PotentiallyHandled:
|
||||
if (IsNonExhaustiveCatch) {
|
||||
|
||||
@@ -9,7 +9,10 @@ func missingAsync<T : AsyncSequence>(_ seq: T) throws {
|
||||
|
||||
@available(SwiftStdlib 5.1, *)
|
||||
func missingThrows<T : AsyncSequence>(_ seq: T) async {
|
||||
for try await _ in seq { } // expected-error{{error is not handled because the enclosing function is not declared 'throws'}}
|
||||
for try await _ in seq { }
|
||||
// expected-error@-1 {{error is not handled because the enclosing function is not declared 'throws'}}
|
||||
// expected-error@-2 {{call can throw, but the error is not handled}}
|
||||
// expected-note@-3 {{call is to 'rethrows' function, but a conformance has a throwing witness}}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.1, *)
|
||||
@@ -27,7 +30,9 @@ func missingThrowingInBlock<T : AsyncSequence>(_ seq: T) {
|
||||
@available(SwiftStdlib 5.1, *)
|
||||
func missingTryInBlock<T : AsyncSequence>(_ seq: T) {
|
||||
executeAsync {
|
||||
for await _ in seq { } // expected-error{{call can throw, but the error is not handled}}
|
||||
for await _ in seq { }
|
||||
// expected-error@-1 2{{call can throw, but the error is not handled}}
|
||||
// expected-note@-2 {{call is to 'rethrows' function, but a conformance has a throwing witness}}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -279,3 +279,14 @@ struct FunctionHolder {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/apple/swift/issues/61368
|
||||
|
||||
@propertyWrapper
|
||||
struct Wrapper {
|
||||
var wrappedValue: Int?
|
||||
init() throws {}
|
||||
}
|
||||
|
||||
struct Repro {
|
||||
@Wrapper var x // expected-error {{call can throw, but errors cannot be thrown out of a property initializer}}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user