Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn check_binding_identifier(ident: &BindingIdentifier, ctx: &SemanticBuilder
// declare function f(eval: number, arguments: number): number; // OK
// declare function f(...eval): number; // OK
// declare function f(...arguments): number; // OK
// type K = (arguments: any[]) => void; // OK
// declare function g({eval, arguments}: {eval: number, arguments: number}): number; // Error
// declare function h([eval, arguments]: [number, number]): number; // Error
let is_declare_function = |kind: &AstKind| {
Expand All @@ -126,7 +127,14 @@ pub fn check_binding_identifier(ident: &BindingIdentifier, ctx: &SemanticBuilder
let parent = ctx.nodes.parent_node(ctx.current_node_id);
let is_ok = match parent.kind() {
AstKind::Function(func) => matches!(func.r#type, FunctionType::TSDeclareFunction),
AstKind::FormalParameter(_) => is_declare_function(&ctx.nodes.parent_kind(parent.id())),
AstKind::FormalParameter(_) => {
is_declare_function(&ctx.nodes.parent_kind(parent.id()))
|| ctx
.nodes
.ancestor_kinds(parent.id())
.nth(1)
.is_some_and(|node| matches!(node, AstKind::TSFunctionType(_)))
}
AstKind::BindingRestElement(_) => {
let grand_parent = ctx.nodes.parent_node(parent.id());
matches!(grand_parent.kind(), AstKind::FormalParameters(_))
Expand Down
1 change: 1 addition & 0 deletions tasks/coverage/misc/pass/arguments-eval.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type K = (arguments: any[]) => void;
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/codegen_misc.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
codegen_misc Summary:
AST Parsed : 43/43 (100.00%)
Positive Passed: 43/43 (100.00%)
AST Parsed : 44/44 (100.00%)
Positive Passed: 44/44 (100.00%)
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/parser_misc.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
parser_misc Summary:
AST Parsed : 43/43 (100.00%)
Positive Passed: 43/43 (100.00%)
AST Parsed : 44/44 (100.00%)
Positive Passed: 44/44 (100.00%)
Negative Passed: 47/47 (100.00%)

× Identifier `b` has already been declared
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/semantic_misc.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
semantic_misc Summary:
AST Parsed : 43/43 (100.00%)
Positive Passed: 27/43 (62.79%)
AST Parsed : 44/44 (100.00%)
Positive Passed: 28/44 (63.64%)
semantic Error: tasks/coverage/misc/pass/oxc-11593.ts
Scope children mismatch:
after transform: ScopeId(0): [ScopeId(1)]
Expand Down
4 changes: 2 additions & 2 deletions tasks/coverage/snapshots/transformer_misc.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
transformer_misc Summary:
AST Parsed : 43/43 (100.00%)
Positive Passed: 43/43 (100.00%)
AST Parsed : 44/44 (100.00%)
Positive Passed: 44/44 (100.00%)
Loading