@@ -1584,10 +1584,22 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
15841584 OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
15851585 }
15861586
1587+ void preserveDiagnoseErrorOnTryFlag () {
1588+ // The "DiagnoseErrorOnTry" flag is a bit of mutable state
1589+ // in the Context itself, used to postpone diagnostic emission
1590+ // to a parent "try" expression. If something was diagnosed
1591+ // during this ContextScope, the flag may have been set, and
1592+ // we need to preseve its value when restoring the old Context.
1593+ bool DiagnoseErrorOnTry = Self.CurContext .shouldDiagnoseErrorOnTry ();
1594+ OldContext.setDiagnoseErrorOnTry (DiagnoseErrorOnTry);
1595+ }
1596+
15871597 void preserveCoverageFromAwaitOperand () {
15881598 OldFlags.mergeFrom (ContextFlags::HasAnyAwait, Self.Flags );
15891599 OldFlags.mergeFrom (ContextFlags::throwFlags (), Self.Flags );
15901600 OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
1601+
1602+ preserveDiagnoseErrorOnTryFlag ();
15911603 }
15921604
15931605 void preserveCoverageFromTryOperand () {
@@ -1606,22 +1618,16 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
16061618 OldFlags.mergeFrom (ContextFlags::HasAnyAsyncSite, Self.Flags );
16071619 OldFlags.mergeFrom (ContextFlags::HasAnyAwait, Self.Flags );
16081620 OldMaxThrowingKind = std::max (OldMaxThrowingKind, Self.MaxThrowingKind );
1621+
1622+ preserveDiagnoseErrorOnTryFlag ();
16091623 }
16101624
16111625 bool wasTopLevelDebuggerFunction () const {
16121626 return OldFlags.has (ContextFlags::IsTopLevelDebuggerFunction);
16131627 }
16141628
16151629 ~ContextScope () {
1616- // The "DiagnoseErrorOnTry" flag is a bit of mutable state
1617- // in the Context itself, used to postpone diagnostic emission
1618- // to a parent "try" expression. If something was diagnosed
1619- // during this ContextScope, the flag may have been set, and
1620- // we need to preseve its value when restoring the old Context.
1621- bool DiagnoseErrorOnTry = Self.CurContext .shouldDiagnoseErrorOnTry ();
16221630 Self.CurContext = OldContext;
1623- Self.CurContext .setDiagnoseErrorOnTry (DiagnoseErrorOnTry);
1624-
16251631 Self.RethrowsDC = OldRethrowsDC;
16261632 Self.Flags = OldFlags;
16271633 Self.MaxThrowingKind = OldMaxThrowingKind;
0 commit comments