Skip to content

Commit 43c374c

Browse files
lauraharkercopybara-github
authored andcommitted
Repro PeepholeDeadCode + @closureUnaware crash
PiperOrigin-RevId: 856792483
1 parent 54cb06a commit 43c374c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/com/google/javascript/jscomp/TranspileAndOptimizeClosureUnawareTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,30 @@ public void testFoldConstants_multipleClosureUnawareBlocksInFile() {
121121
expectedClosureUnaware("console.log(3);", "console.log(33);", "console.log(333);")));
122122
}
123123

124+
@Test
125+
public void testFoldConstants_regressionTest_crashInNodeUtilAddFeatureToScript() {
126+
setLanguageOut(CompilerOptions.LanguageMode.ECMASCRIPT_NEXT);
127+
128+
// TODO: b/421970620 - fix this crash.
129+
assertThrows(
130+
RuntimeException.class,
131+
() ->
132+
testSame(
133+
closureUnaware(
134+
"""
135+
return function f() {
136+
function referenceX() { return x; }
137+
138+
return 1;
139+
140+
// Regression test for a crash in PeepholeRemoveDeadCode.
141+
let x = 0;
142+
referenceX();
143+
x++;
144+
}
145+
""")));
146+
}
147+
124148
@Test
125149
public void testInlineLocalObject() {
126150
test(

0 commit comments

Comments
 (0)