diff --git a/crates/oxc_semantic/examples/cfg.rs b/crates/oxc_semantic/examples/cfg.rs index f0aabb89cf422d..339980754271d5 100644 --- a/crates/oxc_semantic/examples/cfg.rs +++ b/crates/oxc_semantic/examples/cfg.rs @@ -5,7 +5,10 @@ use oxc_allocator::Allocator; use oxc_parser::Parser; use oxc_semantic::{DebugDot, DisplayDot, EdgeType, SemanticBuilder}; use oxc_span::SourceType; -use petgraph::dot::{Config, Dot}; +use petgraph::{ + dot::{Config, Dot}, + visit::EdgeRef, +}; // Instruction: // 1. create a `test.js`, @@ -91,8 +94,10 @@ fn main() -> std::io::Result<()> { &|_graph, edge| { let weight = edge.weight(); let label = format!("label = \"{weight:?}\""); - if matches!(weight, EdgeType::Unreachable) { - format!("{label}, style = \"dotted\"") + if matches!(weight, EdgeType::Unreachable) + || semantic.semantic.cfg().basic_block(edge.source()).unreachable + { + format!("{label}, style = \"dotted\" ") } else { label } diff --git a/crates/oxc_semantic/src/control_flow/builder/mod.rs b/crates/oxc_semantic/src/control_flow/builder/mod.rs index 6573649df7ba27..6c2bb73d77e770 100644 --- a/crates/oxc_semantic/src/control_flow/builder/mod.rs +++ b/crates/oxc_semantic/src/control_flow/builder/mod.rs @@ -4,6 +4,7 @@ use crate::ReturnInstructionKind; use context::Ctx; pub use context::{CtxCursor, CtxFlags}; +use petgraph::Direction; use super::{ AstNodeId, BasicBlock, BasicBlockId, CompactStr, ControlFlowGraph, EdgeType, ErrorEdgeKind, @@ -56,6 +57,17 @@ impl<'a> ControlFlowGraphBuilder<'a> { self.basic_block_mut(self.current_node_ix) } + /// # Panics + pub fn basic_block(&self, basic_block: BasicBlockId) -> &BasicBlock { + let idx = *self + .graph + .node_weight(basic_block) + .expect("expected `self.current_node_ix` to be a valid node index in self.graph"); + self.basic_blocks + .get(idx) + .expect("expected `self.current_node_ix` to be a valid node index in self.graph") + } + /// # Panics pub fn basic_block_mut(&mut self, basic_block: BasicBlockId) -> &mut BasicBlock { let idx = *self @@ -99,6 +111,20 @@ impl<'a> ControlFlowGraphBuilder<'a> { } pub fn add_edge(&mut self, a: BasicBlockId, b: BasicBlockId, weight: EdgeType) { + if matches!(weight, EdgeType::NewFunction) { + self.basic_block_mut(b).unreachable = false; + } else if self.basic_block(a).unreachable { + if self.graph.edges_directed(b, Direction::Incoming).count() == 0 { + self.basic_block_mut(b).unreachable = true; + } + } else if !self + .basic_block(b) + .instructions() + .iter() + .any(|it| matches!(it, Instruction { kind: InstructionKind::Unreachable, .. })) + { + self.basic_block_mut(b).unreachable = false; + } self.graph.add_edge(a, b, weight); } @@ -193,12 +219,13 @@ impl<'a> ControlFlowGraphBuilder<'a> { pub fn append_unreachable(&mut self) { let current_node_ix = self.current_node_ix; let basic_block_with_unreachable_graph_ix = self.new_basic_block_normal(); + self.push_instruction(InstructionKind::Unreachable, None); + self.current_basic_block().unreachable = true; self.add_edge( current_node_ix, basic_block_with_unreachable_graph_ix, EdgeType::Unreachable, ); - self.push_instruction(InstructionKind::Unreachable, None); } #[inline] diff --git a/crates/oxc_semantic/src/control_flow/dot.rs b/crates/oxc_semantic/src/control_flow/dot.rs index a7d7176fb95340..3ad7a810053aec 100644 --- a/crates/oxc_semantic/src/control_flow/dot.rs +++ b/crates/oxc_semantic/src/control_flow/dot.rs @@ -3,7 +3,10 @@ use oxc_ast::{ AstKind, }; use oxc_syntax::node::AstNodeId; -use petgraph::dot::{Config, Dot}; +use petgraph::{ + dot::{Config, Dot}, + visit::EdgeRef, +}; use crate::{ AstNode, AstNodes, BasicBlock, ControlFlowGraph, EdgeType, Instruction, InstructionKind, @@ -56,7 +59,9 @@ impl DisplayDot for ControlFlowGraph { &|_graph, edge| { let weight = edge.weight(); let label = format!("label = \"{weight:?}\" "); - if matches!(weight, EdgeType::Unreachable) { + if matches!(weight, EdgeType::Unreachable) + || self.basic_block(edge.source()).unreachable + { format!("{label}, style = \"dotted\" ") } else { label @@ -115,7 +120,9 @@ impl DebugDot for ControlFlowGraph { &|_graph, edge| { let weight = edge.weight(); let label = format!("label = \"{weight:?}\" "); - if matches!(weight, EdgeType::Unreachable) { + if matches!(weight, EdgeType::Unreachable) + || self.basic_block(edge.source()).unreachable + { format!("{label}, style = \"dotted\" ") } else { label diff --git a/crates/oxc_semantic/src/control_flow/mod.rs b/crates/oxc_semantic/src/control_flow/mod.rs index bf8c2fddc5d1e7..8132bd0f8764b3 100644 --- a/crates/oxc_semantic/src/control_flow/mod.rs +++ b/crates/oxc_semantic/src/control_flow/mod.rs @@ -116,11 +116,12 @@ pub enum CallType { #[derive(Debug)] pub struct BasicBlock { pub instructions: Vec, + pub unreachable: bool, } impl BasicBlock { fn new() -> Self { - BasicBlock { instructions: Vec::new() } + BasicBlock { instructions: Vec::new(), unreachable: false } } pub fn instructions(&self) -> &Vec { diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@break_from_a_label_in_global_scope.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@break_from_a_label_in_global_scope.js-2.snap index 61d72eee3242e6..89fa84890e5f8f 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@break_from_a_label_in_global_scope.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@break_from_a_label_in_global_scope.js-2.snap @@ -9,9 +9,9 @@ digraph { 2 [ label = "unreachable" ] 3 [ label = "" ] 1 -> 0 [ label = "Error(Implicit)" ] - 2 -> 0 [ label = "Error(Implicit)" ] + 2 -> 0 [ label = "Error(Implicit)" , style = "dotted" ] 1 -> 2 [ label = "Unreachable" , style = "dotted" ] 3 -> 0 [ label = "Error(Implicit)" ] - 2 -> 3 [ label = "Normal" ] + 2 -> 3 [ label = "Normal" , style = "dotted" ] 1 -> 3 [ label = "Jump" ] } diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@class_extend_super.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@class_extend_super.js-2.snap index 66778bae8ecd49..676d61370282c4 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@class_extend_super.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@class_extend_super.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@do_while_break.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@do_while_break.js-2.snap index 11592855b50227..0ae64b8f1b8f8f 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@do_while_break.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@do_while_break.js-2.snap @@ -25,14 +25,14 @@ digraph { 6 -> 2 [ label = "Error(Implicit)" ] 4 -> 6 [ label = "Normal" ] 7 -> 2 [ label = "Error(Implicit)" ] - 8 -> 2 [ label = "Error(Implicit)" ] + 8 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 7 -> 8 [ label = "Unreachable" , style = "dotted" ] - 9 -> 2 [ label = "Error(Implicit)" ] + 9 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 10 -> 2 [ label = "Error(Implicit)" ] 6 -> 7 [ label = "Normal" ] - 8 -> 9 [ label = "Normal" ] - 9 -> 10 [ label = "Normal" ] - 9 -> 7 [ label = "Backedge" ] + 8 -> 9 [ label = "Normal" , style = "dotted" ] + 9 -> 10 [ label = "Normal" , style = "dotted" ] + 9 -> 7 [ label = "Backedge" , style = "dotted" ] 7 -> 10 [ label = "Jump" ] 11 -> 2 [ label = "Error(Implicit)" ] 3 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@fn_return_obj_expr_with_computed_key.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@fn_return_obj_expr_with_computed_key.js-2.snap index 45f746813b5846..c24615775cee5e 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@fn_return_obj_expr_with_computed_key.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@fn_return_obj_expr_with_computed_key.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_else.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_else.js-2.snap index e9e3ec79d76d19..03fbb3bc7bf350 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_else.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_else.js-2.snap @@ -28,18 +28,18 @@ digraph { 4 -> 6 [ label = "Normal" ] 5 -> 6 [ label = "Normal" ] 7 -> 2 [ label = "Error(Implicit)" ] - 8 -> 2 [ label = "Error(Implicit)" ] + 8 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 7 -> 8 [ label = "Unreachable" , style = "dotted" ] 9 -> 2 [ label = "Error(Implicit)" ] - 10 -> 2 [ label = "Error(Implicit)" ] + 10 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 9 -> 10 [ label = "Unreachable" , style = "dotted" ] - 11 -> 2 [ label = "Error(Implicit)" ] + 11 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Normal" ] - 8 -> 11 [ label = "Normal" ] + 8 -> 11 [ label = "Normal" , style = "dotted" ] 6 -> 7 [ label = "Jump" ] 3 -> 9 [ label = "Normal" ] - 10 -> 11 [ label = "Normal" ] - 12 -> 2 [ label = "Error(Implicit)" ] + 10 -> 11 [ label = "Normal" , style = "dotted" ] + 12 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 11 -> 12 [ label = "Unreachable" , style = "dotted" ] 13 -> 0 [ label = "Error(Implicit)" ] 1 -> 13 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_stmt_in_for_in.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_stmt_in_for_in.js-2.snap index 27b9276413952a..144adffae41076 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_stmt_in_for_in.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@if_stmt_in_for_in.js-2.snap @@ -30,21 +30,21 @@ digraph { 6 -> 2 [ label = "Error(Implicit)" ] 7 -> 2 [ label = "Error(Implicit)" ] 8 -> 2 [ label = "Error(Implicit)" ] - 9 -> 2 [ label = "Error(Implicit)" ] + 9 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 8 -> 9 [ label = "Unreachable" , style = "dotted" ] 10 -> 2 [ label = "Error(Implicit)" ] 11 -> 2 [ label = "Error(Implicit)" ] 12 -> 2 [ label = "Error(Implicit)" ] - 13 -> 2 [ label = "Error(Implicit)" ] + 13 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 12 -> 13 [ label = "Unreachable" , style = "dotted" ] 14 -> 2 [ label = "Error(Implicit)" ] 10 -> 11 [ label = "Normal" ] - 13 -> 14 [ label = "Normal" ] + 13 -> 14 [ label = "Normal" , style = "dotted" ] 11 -> 12 [ label = "Jump" ] 10 -> 14 [ label = "Normal" ] 15 -> 2 [ label = "Error(Implicit)" ] 6 -> 7 [ label = "Normal" ] - 9 -> 15 [ label = "Normal" ] + 9 -> 15 [ label = "Normal" , style = "dotted" ] 7 -> 8 [ label = "Jump" ] 6 -> 10 [ label = "Normal" ] 14 -> 15 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labeled_block_break.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labeled_block_break.js-2.snap index 42961689c6d6d4..a0d1fc84d007df 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labeled_block_break.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labeled_block_break.js-2.snap @@ -21,11 +21,11 @@ digraph { 2 -> 4 [ label = "Normal" ] 5 -> 0 [ label = "Error(Implicit)" ] 6 -> 0 [ label = "Error(Implicit)" ] - 7 -> 0 [ label = "Error(Implicit)" ] + 7 -> 0 [ label = "Error(Implicit)" , style = "dotted" ] 6 -> 7 [ label = "Unreachable" , style = "dotted" ] 8 -> 0 [ label = "Error(Implicit)" ] 4 -> 5 [ label = "Normal" ] - 7 -> 8 [ label = "Normal" ] + 7 -> 8 [ label = "Normal" , style = "dotted" ] 5 -> 6 [ label = "Jump" ] 4 -> 8 [ label = "Normal" ] 9 -> 0 [ label = "Error(Implicit)" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labelled_try_break.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labelled_try_break.js-2.snap index b8baea190c923c..afd46db9da5a0c 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labelled_try_break.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@labelled_try_break.js-2.snap @@ -22,20 +22,20 @@ digraph { 1 -> 3 [ label = "NewFunction" ] 5 -> 2 [ label = "Error(Implicit)" ] 5 -> 4 [ label = "Finalize" ] - 6 -> 2 [ label = "Error(Implicit)" ] - 6 -> 4 [ label = "Finalize" ] + 6 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] + 6 -> 4 [ label = "Finalize" , style = "dotted" ] 5 -> 6 [ label = "Unreachable" , style = "dotted" ] 7 -> 2 [ label = "Error(Implicit)" ] 4 -> 7 [ label = "Normal" ] - 8 -> 2 [ label = "Error(Implicit)" ] + 8 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 7 -> 8 [ label = "Unreachable" , style = "dotted" ] - 9 -> 2 [ label = "Error(Implicit)" ] + 9 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 5 [ label = "Normal" ] - 8 -> 9 [ label = "Join" ] + 8 -> 9 [ label = "Join" , style = "dotted" ] 10 -> 2 [ label = "Error(Implicit)" ] - 9 -> 10 [ label = "Normal" ] + 9 -> 10 [ label = "Normal" , style = "dotted" ] 7 -> 10 [ label = "Jump" ] - 11 -> 2 [ label = "Error(Implicit)" ] + 11 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 10 -> 11 [ label = "Unreachable" , style = "dotted" ] 12 -> 0 [ label = "Error(Implicit)" ] 1 -> 12 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_numbered_index.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_numbered_index.js-2.snap index 9cb22c90d79b61..ecaa2dbb02036c 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_numbered_index.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_numbered_index.js-2.snap @@ -14,9 +14,9 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] - 5 -> 2 [ label = "Error(Implicit)" ] + 5 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 4 -> 5 [ label = "Unreachable" , style = "dotted" ] 6 -> 0 [ label = "Error(Implicit)" ] 1 -> 6 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_unreachable.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_unreachable.js-2.snap index 6e3f96ef237e36..812c386f6d9689 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_unreachable.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@member_access_with_unreachable.js-2.snap @@ -14,9 +14,9 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] - 5 -> 2 [ label = "Error(Implicit)" ] + 5 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 4 -> 5 [ label = "Unreachable" , style = "dotted" ] 6 -> 0 [ label = "Error(Implicit)" ] 1 -> 6 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@nested_computed_member_expression.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@nested_computed_member_expression.js-2.snap index 71db210af344e3..6a5e9c35e777a2 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@nested_computed_member_expression.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@nested_computed_member_expression.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@private_in.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@private_in.js-2.snap index b8b0303934bd86..54d2b873046872 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@private_in.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@private_in.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@simple_spread.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@simple_spread.js-2.snap index bce3168832683f..c3c9d1e423d631 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@simple_spread.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@simple_spread.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@spread_in_a_spread.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@spread_in_a_spread.js-2.snap index f29099722d1582..1a1191bc2ba1bb 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@spread_in_a_spread.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@spread_in_a_spread.js-2.snap @@ -13,7 +13,7 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_in_while.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_in_while.js-2.snap index 6988bc7358edef..a0e039acb93bc4 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_in_while.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_in_while.js-2.snap @@ -21,13 +21,13 @@ digraph { 4 -> 0 [ label = "Error(Implicit)" ] 5 -> 0 [ label = "Error(Implicit)" ] 4 -> 5 [ label = "Jump" ] - 6 -> 0 [ label = "Error(Implicit)" ] + 6 -> 0 [ label = "Error(Implicit)" , style = "dotted" ] 5 -> 6 [ label = "Unreachable" , style = "dotted" ] 7 -> 0 [ label = "Error(Implicit)" ] 8 -> 0 [ label = "Error(Implicit)" ] 7 -> 8 [ label = "Jump" ] 4 -> 7 [ label = "Normal" ] - 6 -> 7 [ label = "Normal" ] + 6 -> 7 [ label = "Normal" , style = "dotted" ] 3 -> 4 [ label = "Normal" ] 3 -> 7 [ label = "Normal" ] 9 -> 0 [ label = "Error(Implicit)" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_statement.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_statement.js-2.snap index 7cbab061e6157e..30af5749257911 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_statement.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@switch_statement.js-2.snap @@ -33,7 +33,7 @@ digraph { 4 -> 2 [ label = "Error(Implicit)" ] 5 -> 2 [ label = "Error(Implicit)" ] 4 -> 5 [ label = "Jump" ] - 6 -> 2 [ label = "Error(Implicit)" ] + 6 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 5 -> 6 [ label = "Unreachable" , style = "dotted" ] 7 -> 2 [ label = "Error(Implicit)" ] 8 -> 2 [ label = "Error(Implicit)" ] @@ -41,12 +41,12 @@ digraph { 9 -> 2 [ label = "Error(Implicit)" ] 10 -> 2 [ label = "Error(Implicit)" ] 9 -> 10 [ label = "Jump" ] - 11 -> 2 [ label = "Error(Implicit)" ] + 11 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 10 -> 11 [ label = "Unreachable" , style = "dotted" ] 12 -> 2 [ label = "Error(Implicit)" ] 13 -> 2 [ label = "Error(Implicit)" ] 12 -> 13 [ label = "Jump" ] - 14 -> 2 [ label = "Error(Implicit)" ] + 14 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 13 -> 14 [ label = "Unreachable" , style = "dotted" ] 15 -> 2 [ label = "Error(Implicit)" ] 16 -> 2 [ label = "Error(Implicit)" ] @@ -54,14 +54,14 @@ digraph { 17 -> 2 [ label = "Error(Implicit)" ] 18 -> 2 [ label = "Error(Implicit)" ] 17 -> 18 [ label = "Jump" ] - 19 -> 2 [ label = "Error(Implicit)" ] + 19 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 18 -> 19 [ label = "Unreachable" , style = "dotted" ] 4 -> 7 [ label = "Normal" ] 4 -> 9 [ label = "Normal" ] 4 -> 12 [ label = "Normal" ] 4 -> 15 [ label = "Normal" ] 4 -> 17 [ label = "Normal" ] - 6 -> 7 [ label = "Normal" ] + 6 -> 7 [ label = "Normal" , style = "dotted" ] 3 -> 4 [ label = "Normal" ] 7 -> 9 [ label = "Normal" ] 7 -> 12 [ label = "Normal" ] @@ -72,21 +72,21 @@ digraph { 9 -> 12 [ label = "Normal" ] 9 -> 15 [ label = "Normal" ] 9 -> 17 [ label = "Normal" ] - 11 -> 12 [ label = "Normal" ] + 11 -> 12 [ label = "Normal" , style = "dotted" ] 3 -> 9 [ label = "Normal" ] 12 -> 15 [ label = "Normal" ] 12 -> 17 [ label = "Normal" ] - 14 -> 15 [ label = "Normal" ] + 14 -> 15 [ label = "Normal" , style = "dotted" ] 3 -> 12 [ label = "Normal" ] 15 -> 17 [ label = "Normal" ] 16 -> 17 [ label = "Normal" ] 3 -> 15 [ label = "Normal" ] 3 -> 17 [ label = "Normal" ] 20 -> 2 [ label = "Error(Implicit)" ] - 19 -> 20 [ label = "Normal" ] + 19 -> 20 [ label = "Normal" , style = "dotted" ] 5 -> 20 [ label = "Jump" ] 10 -> 20 [ label = "Jump" ] - 21 -> 2 [ label = "Error(Implicit)" ] + 21 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 20 -> 21 [ label = "Unreachable" , style = "dotted" ] 22 -> 0 [ label = "Error(Implicit)" ] 1 -> 22 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@two_functions.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@two_functions.js-2.snap index 7dfee70278ad2a..f37871f22eaa63 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@two_functions.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@two_functions.js-2.snap @@ -17,13 +17,13 @@ digraph { 1 -> 0 [ label = "Error(Implicit)" ] 3 -> 2 [ label = "Error(Implicit)" ] 1 -> 3 [ label = "NewFunction" ] - 4 -> 2 [ label = "Error(Implicit)" ] + 4 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 3 -> 4 [ label = "Unreachable" , style = "dotted" ] 5 -> 0 [ label = "Error(Implicit)" ] 1 -> 5 [ label = "Normal" ] 7 -> 6 [ label = "Error(Implicit)" ] 5 -> 7 [ label = "NewFunction" ] - 8 -> 6 [ label = "Error(Implicit)" ] + 8 -> 6 [ label = "Error(Implicit)" , style = "dotted" ] 7 -> 8 [ label = "Unreachable" , style = "dotted" ] 9 -> 0 [ label = "Error(Implicit)" ] 5 -> 9 [ label = "Normal" ] diff --git a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@while.js-2.snap b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@while.js-2.snap index 7baa8c6f056539..d6c241422813e2 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@while.js-2.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/integration__cfg__cfg_files@while.js-2.snap @@ -26,14 +26,14 @@ digraph { 4 -> 6 [ label = "Normal" ] 5 -> 6 [ label = "Normal" ] 7 -> 2 [ label = "Error(Implicit)" ] - 8 -> 2 [ label = "Error(Implicit)" ] + 8 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 7 -> 8 [ label = "Unreachable" , style = "dotted" ] 9 -> 2 [ label = "Error(Implicit)" ] 3 -> 4 [ label = "Normal" ] 4 -> 7 [ label = "Jump" ] - 8 -> 4 [ label = "Backedge" ] + 8 -> 4 [ label = "Backedge" , style = "dotted" ] 4 -> 9 [ label = "Normal" ] - 10 -> 2 [ label = "Error(Implicit)" ] + 10 -> 2 [ label = "Error(Implicit)" , style = "dotted" ] 9 -> 10 [ label = "Unreachable" , style = "dotted" ] 11 -> 0 [ label = "Error(Implicit)" ] 1 -> 11 [ label = "Normal" ]