Skip to content

Commit 831928d

Browse files
authored
fix(minifier): mark as changed when else if was converted to if (#8837)
This PR fixes this fail in monitor-oxc. https://github.com/oxc-project/monitor-oxc/actions/runs/13096316109/job/36539024628#step:8:14
1 parent dc4c388 commit 831928d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

crates/oxc_minifier/src/peephole/minimize_statements.rs

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ impl<'a> PeepholeOptimizations {
262262
if if_stmt.consequent.is_jump_statement() {
263263
if let Some(stmt) = if_stmt.alternate.take() {
264264
result.push(stmt);
265+
self.mark_current_function_as_changed();
265266
continue;
266267
}
267268
}

crates/oxc_minifier/tests/peephole/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ fn integration() {
7676
console.log(c, d);
7777
",
7878
);
79+
80+
test(
81+
"function _() {
82+
if (currentChar === '\\n')
83+
return pos + 1;
84+
else if (currentChar !== ' ' && currentChar !== '\\t')
85+
return pos + 1;
86+
}",
87+
"function _() {
88+
if (currentChar === '\\n' || currentChar !== ' ' && currentChar !== '\\t')
89+
return pos + 1;
90+
}",
91+
);
7992
}
8093

8194
#[test]

0 commit comments

Comments
 (0)