]> git.kaiwu.me - quickjs.git/commitdiff
fix anonymous function name inference in for-in loop initializers
authorFabrice Bellard <fabrice@bellard.org>
Tue, 29 Sep 2026 10:21:26 +0000 (12:21 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 29 Sep 2026 10:21:26 +0000 (12:21 +0200)
quickjs.c
test262_errors.txt

index f1c696e83e394959c9bd1d993b088524ba5c70d8..b0395d750998ab2a4a6397093e6c9c95edddedef 100644 (file)
--- 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);
index e0ff14502fc3f1de7afeaa60c040405e0b83ee53..5f2b43c3bab0473dee7811e4511e7613736c3536 100644 (file)
@@ -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