Skip to content

Commit 1658e2f

Browse files
authored
Merge pull request #11618 from webpack/bugfix/11615
fixes crash in SideEffectsFlagPlugin
2 parents 5573fed + a8fb45d commit 1658e2f

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/optimize/SideEffectsFlagPlugin.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,20 @@ class SideEffectsFlagPlugin {
129129
case "ForStatement":
130130
if (
131131
!parser.isPure(statement.init, statement.range[0]) ||
132-
!parser.isPure(statement.test, statement.init.range[1]) ||
133-
!parser.isPure(statement.update, statement.test.range[1])
132+
!parser.isPure(
133+
statement.test,
134+
statement.init
135+
? statement.init.range[1]
136+
: statement.range[0]
137+
) ||
138+
!parser.isPure(
139+
statement.update,
140+
statement.test
141+
? statement.test.range[1]
142+
: statement.init
143+
? statement.init.range[1]
144+
: statement.range[0]
145+
)
134146
) {
135147
hasSideEffects = true;
136148
}

test/cases/side-effects/empty-modules/pure.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ const class2 = class {
2626
if ("") {
2727
console.log("test");
2828
}
29+
for (; false; ) {}
30+
for (var i = 0; false; ) {}
31+
while (false) {}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy