diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index 6b64fcb6022a9..6b2bf167f2df5 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -651,7 +651,7 @@ pub fn check_function_redeclaration(func: &Function, ctx: &SemanticBuilder<'_>) let current_scope_flags = ctx.current_scope_flags(); if prev.flags.intersects(SymbolFlags::FunctionScopedVariable | SymbolFlags::Function) && (current_scope_flags.is_function() - || (ctx.source_type.is_script() && current_scope_flags.is_top())) + || (!ctx.source_type.is_module() && current_scope_flags.is_top())) { // https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames // `function a() {}; function a() {}` and `var a; function a() {}` are