@@ -15,30 +15,33 @@ export default class LabeledStatement extends StatementBase {
1515 declare type : NodeType . tLabeledStatement ;
1616
1717 hasEffects ( context : HasEffectsContext ) : boolean {
18- const brokenFlow = context . brokenFlow ;
18+ const { brokenFlow, includedLabels } = context ;
1919 context . ignore . labels . add ( this . label . name ) ;
20- if ( this . body . hasEffects ( context ) ) return true ;
21- context . ignore . labels . delete ( this . label . name ) ;
22- if ( context . includedLabels . has ( this . label . name ) ) {
23- context . includedLabels . delete ( this . label . name ) ;
24- context . brokenFlow = brokenFlow ;
20+ context . includedLabels = new Set < string > ( ) ;
21+ let bodyHasEffects = false ;
22+ if ( this . body . hasEffects ( context ) ) {
23+ bodyHasEffects = true ;
24+ } else {
25+ context . ignore . labels . delete ( this . label . name ) ;
26+ if ( context . includedLabels . has ( this . label . name ) ) {
27+ context . includedLabels . delete ( this . label . name ) ;
28+ context . brokenFlow = brokenFlow ;
29+ }
2530 }
26- return false ;
31+ context . includedLabels = new Set ( [ ...includedLabels , ...context . includedLabels ] ) ;
32+ return bodyHasEffects ;
2733 }
2834
2935 include ( context : InclusionContext , includeChildrenRecursively : IncludeChildren ) : void {
3036 this . included = true ;
3137 const { brokenFlow, includedLabels } = context ;
3238 context . includedLabels = new Set < string > ( ) ;
3339 this . body . include ( context , includeChildrenRecursively ) ;
34- // eslint-disable-next-line unicorn/consistent-destructuring
3540 if ( includeChildrenRecursively || context . includedLabels . has ( this . label . name ) ) {
3641 this . label . include ( ) ;
37- // eslint-disable-next-line unicorn/consistent-destructuring
3842 context . includedLabels . delete ( this . label . name ) ;
3943 context . brokenFlow = brokenFlow ;
4044 }
41- // eslint-disable-next-line unicorn/consistent-destructuring
4245 context . includedLabels = new Set ( [ ...includedLabels , ...context . includedLabels ] ) ;
4346 }
4447
0 commit comments