fix(rome_js_analyze): fix how control flow edges are generated in for-statements with no test node
MODIFY
crates/rome_js_analyze/src/control_flow/nodes/for_stmt.rs
crates/rome_js_analyze/src/control_flow/nodes/for_stmt.rs
@@ -90,6 +90,8 @@ impl NodeVisitor for ForVisitor {
builder
.append_jump(true, loop_block)
.with_node(test.syntax().clone());
+ } else {
+ builder.append_jump(false, loop_block);
}
builder.append_jump(false, break_block);

MODIFY
crates/rome_js_analyze/tests/specs/nursery/noUnreachable/JsForStatement.js
crates/rome_js_analyze/tests/specs/nursery/noUnreachable/JsForStatement.js
@@ -3,3 +3,8 @@ function JsForStatement1() {
break;
}
}
+
+function JsForStatement2() {
+ for (;;) {}
+ afterLoop();
+}

fix(rome_js_analyze): fix how control flow edges are generated in for-statements with no test node (#3516)