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
13 changes: 11 additions & 2 deletions crates/oxc_semantic/src/checker/javascript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,27 @@ pub fn check_identifier_reference(ident: &IdentifierReference, ctx: &SemanticBui
// It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList is true.

if ident.name == "arguments" {
let mut previous_node_address = ctx.nodes.get_node(ctx.current_node_id).address();
for node_kind in ctx.nodes.ancestor_kinds(ctx.current_node_id) {
match node_kind {
AstKind::Function(_) => break,
AstKind::PropertyDefinition(_) => {
return ctx.error(unexpected_arguments("class field initializer", ident.span));
AstKind::PropertyDefinition(prop) => {
if prop
.value
.as_ref()
.is_some_and(|value| value.address() == previous_node_address)
{
return ctx
.error(unexpected_arguments("class field initializer", ident.span));
}
}
AstKind::StaticBlock(_) => {
return ctx
.error(unexpected_arguments("static initialization block", ident.span));
}
_ => {}
}
previous_node_address = node_kind.address();
}
}
}
Expand Down
13 changes: 1 addition & 12 deletions tasks/coverage/snapshots/parser_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: 4cc3d888

parser_babel Summary:
AST Parsed : 2422/2440 (99.26%)
Positive Passed: 2395/2440 (98.16%)
Positive Passed: 2396/2440 (98.20%)
Negative Passed: 1685/1752 (96.18%)
Expect Syntax Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/private-in/invalid-private-followed-by-in-2/input.js

Expand Down Expand Up @@ -266,17 +266,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/core/s
2 │ {}
╰────

Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/arguments-in-key/input.js

× 'arguments' is not allowed in class field initializer
╭─[babel/packages/babel-parser/test/fixtures/es2022/class-properties/arguments-in-key/input.js:3:6]
2 │ class A {
3 │ [arguments] = 2;
· ─────────
4 │ }
╰────
help: Assign the 'arguments' variable to a temporary variable outside

Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/new-target/input.js

× Unexpected new.target expression
Expand Down
5 changes: 1 addition & 4 deletions tasks/coverage/snapshots/semantic_babel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ commit: 4cc3d888

semantic_babel Summary:
AST Parsed : 2440/2440 (100.00%)
Positive Passed: 2006/2440 (82.21%)
Positive Passed: 2007/2440 (82.25%)
semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/valid-assignment-target-type/input.js
Cannot assign to this expression

Expand Down Expand Up @@ -101,9 +101,6 @@ Symbol scope ID mismatch for "_x":
after transform: SymbolId(1): ScopeId(1)
rebuilt : SymbolId(2): ScopeId(0)

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/arguments-in-key/input.js
'arguments' is not allowed in class field initializer

semantic Error: tasks/coverage/babel/packages/babel-parser/test/fixtures/es2022/class-properties/await-identifier-in-computed-property-inside-params-of-function-inside-params-of-async-function/input.js
Bindings mismatch:
after transform: ScopeId(0): ["_asyncToGenerator", "_defineProperty"]
Expand Down
Loading