Skip to content

Commit 278fcb6

Browse files
fix: dead control flow with deep nested if (#19403)
1 parent 44da94f commit 278fcb6

22 files changed

Lines changed: 442 additions & 13 deletions

lib/javascript/JavascriptParser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,6 +2200,9 @@ class JavascriptParser extends Parser {
22002200
this.inExecutedPath(false, () => {
22012201
this.walkExpression(statement.test);
22022202
this.walkNestedStatement(statement.consequent);
2203+
});
2204+
2205+
this.inExecutedPath(true, () => {
22032206
if (statement.alternate) {
22042207
this.walkNestedStatement(statement.alternate);
22052208
}

test/__snapshots__/StatsTestCases.basictest.js.snap

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4781,22 +4781,15 @@ exports[`StatsTestCases should print correct stats for track-returned 1`] = `
47814781
./used8.js X bytes [built] [code generated]
47824782
./used9.js X bytes [built] [code generated]
47834783
./used16.js X bytes [built] [code generated]
4784+
./used69.js X bytes [built] [code generated]
47844785
./used17.js X bytes [built] [code generated]
47854786
./used18.js X bytes [built] [code generated]
47864787
./used19.js X bytes [built] [code generated]
47874788
./used48.js X bytes [built] [code generated]
47884789
./used35.js X bytes [built] [code generated]
47894790
./used10.js X bytes [built] [code generated]
4790-
./used11.js X bytes [built] [code generated]
4791-
+ 38 modules
4792-
4793-
WARNING in ./index.js 227:3-20
4794-
Module not found: Error: Can't resolve 'fail47' in 'Xdir/track-returned'
4795-
4796-
1 warning has detailed information that is not shown.
4797-
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
4798-
4799-
webpack x.x.x compiled with 1 warning in X ms"
4791+
+ 56 modules
4792+
webpack x.x.x compiled successfully in X ms"
48004793
`;
48014794
48024795
exports[`StatsTestCases should print correct stats for tree-shaking 1`] = `

0 commit comments

Comments
 (0)