From 13876a25d59065613366f6947a5471e29af4797c Mon Sep 17 00:00:00 2001 From: Fabrice Bellard Date: Tue, 29 Sep 2026 12:21:26 +0200 Subject: [PATCH] fix anonymous function name inference in for-in loop initializers --- quickjs.c | 3 +++ test262_errors.txt | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/quickjs.c b/quickjs.c index f1c696e..b0395d7 100644 --- a/quickjs.c +++ b/quickjs.c @@ -28964,6 +28964,7 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, pos_expr = s->cur_func->byte_code.size; emit_label(s, label_expr); if (s->token.val == '=') { + const uint8_t *source_ptr = s->token.ptr; /* XXX: potential scoping issue if inside `with` statement */ has_initializer = TRUE; /* parse and evaluate initializer prior to evaluating the @@ -28973,6 +28974,8 @@ static __exception int js_parse_for_in_of(JSParseState *s, int label_name, JS_FreeAtom(ctx, var_name); return -1; } + set_object_name(s, var_name); + emit_source_pos(s, source_ptr); if (var_name != JS_ATOM_NULL) { emit_op(s, OP_scope_put_var); emit_atom(s, var_name); diff --git a/test262_errors.txt b/test262_errors.txt index e0ff145..5f2b43c 100644 --- a/test262_errors.txt +++ b/test262_errors.txt @@ -14,7 +14,6 @@ test262/test/language/expressions/compound-assignment/S11.13.2_A6.11_T1.js:24: T test262/test/staging/sm/Function/arguments-parameter-shadowing.js:14: Test262Error: Expected SameValue(«true», «false») to be true test262/test/staging/sm/Function/constructor-binding.js:11: Test262Error: Expected SameValue(«"function"», «"undefined"») to be true test262/test/staging/sm/Function/function-bind.js:24: Test262Error: Conforms to NativeFunction Syntax: "function bound unbound() {\n [native code]\n}" -test262/test/staging/sm/Function/function-name-for.js:13: Test262Error: Expected SameValue(«""», «"forInHead"») to be true test262/test/staging/sm/Function/implicit-this-in-parameter-expression.js:12: Test262Error: Expected SameValue(«[object Object]», «undefined») to be true test262/test/staging/sm/Function/invalid-parameter-list.js:13: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all test262/test/staging/sm/class/boundFunctionSubclassing.js:9: Test262Error: Expected SameValue(«false», «true») to be true -- 2.47.3