From 3659e6d768804ac8ec37f6def3cf5b1ff31d801e Mon Sep 17 00:00:00 2001 From: Jan Olaf Martin Date: Fri, 13 Dec 2024 20:09:28 -0800 Subject: [PATCH] fix(cfg): include export default code in CFG instructions (#7862) Previously any instructions happening inside of the expression passed to `export default` were invisible in the CFG. Example: ``` // Uncommenting this line makes the call to bar() disappear from the // CFG view of the program: // export default bar(); ``` --- crates/oxc_ast/src/ast_kind_impl.rs | 2 +- .../tests/integration/snapshots/function_as_expression.snap | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/oxc_ast/src/ast_kind_impl.rs b/crates/oxc_ast/src/ast_kind_impl.rs index 11d8c5fa7..0752b1e18 100644 --- a/crates/oxc_ast/src/ast_kind_impl.rs +++ b/crates/oxc_ast/src/ast_kind_impl.rs @@ -12,7 +12,7 @@ impl<'a> AstKind<'a> { | Self::DebuggerStatement(_) | Self::EmptyStatement(_) | Self::ExpressionStatement(_) | Self::LabeledStatement(_) | Self::ReturnStatement(_) | Self::SwitchStatement(_) | Self::ThrowStatement(_) | Self::TryStatement(_) | Self::WithStatement(_) - | Self::IfStatement(_) | Self::VariableDeclaration(_)) + | Self::IfStatement(_) | Self::VariableDeclaration(_) | Self::ExportDefaultDeclaration(_)) } #[rustfmt::skip] diff --git a/crates/oxc_semantic/tests/integration/snapshots/function_as_expression.snap b/crates/oxc_semantic/tests/integration/snapshots/function_as_expression.snap index 840cc2cd2..9375fc249 100644 --- a/crates/oxc_semantic/tests/integration/snapshots/function_as_expression.snap +++ b/crates/oxc_semantic/tests/integration/snapshots/function_as_expression.snap @@ -33,7 +33,7 @@ bb6: { } bb7: { - + statement } bb8: { @@ -172,7 +172,8 @@ ExpressionStatement" shape = box] 5 [ label = "bb5" shape = box] 6 [ label = "bb6 return" shape = box] - 7 [ label = "bb7" shape = box] + 7 [ label = "bb7 +ExportDefaultDeclaration" shape = box] 8 [ label = "bb8" shape = box] 9 [ label = "bb9 return" shape = box]