diff --git a/crates/oxc_semantic/src/checker/javascript.rs b/crates/oxc_semantic/src/checker/javascript.rs index 668bdf1649a72..d03be9aad0495 100644 --- a/crates/oxc_semantic/src/checker/javascript.rs +++ b/crates/oxc_semantic/src/checker/javascript.rs @@ -686,6 +686,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() + || current_scope_flags.is_class_static_block() || (!ctx.source_type.is_module() && current_scope_flags.is_top())) { // https://tc39.github.io/ecma262/#sec-scripts-static-semantics-lexicallydeclarednames diff --git a/tasks/coverage/snapshots/parser_babel.snap b/tasks/coverage/snapshots/parser_babel.snap index 5e56000bbfd50..b4a7d5e0c1a6b 100644 --- a/tasks/coverage/snapshots/parser_babel.snap +++ b/tasks/coverage/snapshots/parser_babel.snap @@ -2,7 +2,7 @@ commit: fc58af40 parser_babel Summary: AST Parsed : 2221/2227 (99.73%) -Positive Passed: 2206/2227 (99.06%) +Positive Passed: 2207/2227 (99.10%) Negative Passed: 1649/1689 (97.63%) Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2026/explicit-resource-management/invalid-for-using-of-no-initializer/input.js @@ -84,20 +84,6 @@ Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/ty Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/typescript/types/invalid-import-type-options-with-spread-element/input.ts -Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-static-block/duplicate-function-var-name/input.js - - × Identifier `x` has already been declared - ╭─[babel/packages/babel-parser/test/fixtures/es2022/class-static-block/duplicate-function-var-name/input.js:3:11] - 2 │ static { - 3 │ var x; - · ┬ - · ╰── `x` has already been declared here - 4 │ function x() {} - · ┬ - · ╰── It can not be redeclared here - 5 │ } - ╰──── - Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/top-level-await-unambiguous/module/input.js × `await` is only allowed within async functions and at the top levels of modules diff --git a/tasks/coverage/snapshots/semantic_babel.snap b/tasks/coverage/snapshots/semantic_babel.snap index bf8e3e0c2e6e0..aba50aed91057 100644 --- a/tasks/coverage/snapshots/semantic_babel.snap +++ b/tasks/coverage/snapshots/semantic_babel.snap @@ -2,7 +2,7 @@ commit: fc58af40 semantic_babel Summary: AST Parsed : 2227/2227 (100.00%) -Positive Passed: 1940/2227 (87.11%) +Positive Passed: 1941/2227 (87.16%) semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/comments/decorators/decorators-after-export/input.js Symbol span mismatch for "C": after transform: SymbolId(0): Span { start: 65, end: 66 } @@ -76,9 +76,6 @@ Symbol scope ID mismatch for "_await": after transform: SymbolId(3): ScopeId(2) rebuilt : SymbolId(2): ScopeId(0) -semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-static-block/duplicate-function-var-name/input.js -Identifier `x` has already been declared - semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/top-level-await-unambiguous/module/input.js `await` is only allowed within async functions and at the top levels of modules