diff --git a/crates/oxc_semantic/src/binder.rs b/crates/oxc_semantic/src/binder.rs index 9bd0010b6..17b972466 100644 --- a/crates/oxc_semantic/src/binder.rs +++ b/crates/oxc_semantic/src/binder.rs @@ -146,7 +146,7 @@ impl<'a> Binder for Function<'a> { let symbol_id = builder.declare_symbol( ident.span, &ident.name, - SymbolFlags::empty(), + SymbolFlags::Function, SymbolFlags::empty(), ); ident.symbol_id.set(Some(symbol_id)); diff --git a/crates/oxc_semantic/tests/symbols.rs b/crates/oxc_semantic/tests/symbols.rs index d2054d2e7..1dbaa81d0 100644 --- a/crates/oxc_semantic/tests/symbols.rs +++ b/crates/oxc_semantic/tests/symbols.rs @@ -26,6 +26,18 @@ fn test_function_simple() { .test(); } +#[test] +fn test_function_expressions() { + SemanticTester::js("const x = function y() {}") + .has_some_symbol("y") + .contains_flags(SymbolFlags::Function) + .test(); + SemanticTester::js("const x = () => {}") + .has_some_symbol("x") + .contains_flags(SymbolFlags::BlockScopedVariable | SymbolFlags::ConstVariable) + .test(); +} + #[test] fn test_var_simple() { SemanticTester::js("let x; { let y; }")