perf(semantic): skip arguments ancestry checks outside classes (#28510)

Skip ContainsArguments ancestor traversal when no class is active;
retain field initializer and static block checks.

AI-assisted (Codex).
This commit is contained in:
Boshen authored and GitHub committed 2026-10-30 17:17:34 +08:00
1 parent cf81d074eb
commit d85ee3db01
1 file changed
+1 -1
@@ -316,7 +316,7 @@ pub fn check_identifier_reference(ident: &IdentifierReference, ctx: &SemanticBui
// ClassStaticBlockBody : ClassStaticBlockStatementList
// It is a Syntax Error if ContainsArguments of ClassStaticBlockStatementList is true.
if ident.name == "arguments" {
if ident.name == "arguments" && ctx.class_table_builder.current_class_id.is_some() {
let mut previous_node_address = ctx.ancestry().current_address();
for node_kind in ctx.ancestry().ancestor_kinds() {
match node_kind {