Skip to content

Commit

Permalink
fix: connect test expression of for statements to the cfg.
Browse files Browse the repository at this point in the history
I don't know if it is correct or not, Fixes my issues with dangling cfg
nodes created in for statements.
  • Loading branch information
rzvxa committed May 9, 2024
1 parent 9525653 commit 2a8148a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
}

/* cfg */
let after_test_graph_ix = self.cfg.current_node_ix;
let update_graph_ix = self.cfg.new_basic_block();
/* cfg */

Expand All @@ -803,10 +804,10 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
/* cfg */
let after_for_stmt = self.cfg.new_basic_block();
self.cfg.add_edge(before_for_graph_ix, test_graph_ix, EdgeType::Normal);
self.cfg.add_edge(test_graph_ix, body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(after_test_graph_ix, body_graph_ix, EdgeType::Normal);
self.cfg.add_edge(body_graph_ix, update_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(update_graph_ix, test_graph_ix, EdgeType::Backedge);
self.cfg.add_edge(test_graph_ix, after_for_stmt, EdgeType::Normal);
self.cfg.add_edge(after_test_graph_ix, after_for_stmt, EdgeType::Normal);

self.cfg.after_statement(
&statement_state,
Expand Down

0 comments on commit 2a8148a

Please sign in to comment.