From: Fabrice Bellard Date: Tue, 29 Sep 2026 10:10:31 +0000 (+0200) Subject: fix super property assignment on non-extensible receiver with existing property X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=fce112dd0b03b82b28b0259347975fe28db9e845;p=quickjs.git fix super property assignment on non-extensible receiver with existing property --- diff --git a/quickjs.c b/quickjs.c index 51ea4e2..f1c696e 100644 --- a/quickjs.c +++ b/quickjs.c @@ -9881,17 +9881,16 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj, return JS_ThrowTypeErrorOrFalse(ctx, flags, "not an object"); } - if (unlikely(!p->extensible)) { - JS_FreeValue(ctx, val); - return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible"); - } - if (likely(p == JS_VALUE_GET_OBJ(obj))) { if (p->is_exotic) { if (p->class_id == JS_CLASS_ARRAY && p->fast_array && __JS_AtomIsTaggedInt(prop)) { uint32_t idx = __JS_AtomToUInt32(prop); if (idx == p->u.array.count) { + if (unlikely(!p->extensible)) { + JS_FreeValue(ctx, val); + return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible"); + } /* fast case */ return add_fast_array_element(ctx, p, val, flags); } else { @@ -9903,6 +9902,10 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj, } else { if (unlikely(p->class_id == JS_CLASS_GLOBAL_OBJECT)) goto generic_create_prop; + if (unlikely(!p->extensible)) { + JS_FreeValue(ctx, val); + return JS_ThrowTypeErrorOrFalse(ctx, flags, "object is not extensible"); + } pr = add_property(ctx, p, prop, JS_PROP_C_W_E); if (unlikely(!pr)) { JS_FreeValue(ctx, val); @@ -9940,6 +9943,7 @@ int JS_SetPropertyInternal(JSContext *ctx, JSValueConst obj, return ret; } else { generic_create_prop: + /* the extensibility test is included in JS_CreateProperty() */ ret = JS_CreateProperty(ctx, p, prop, val, JS_UNDEFINED, JS_UNDEFINED, flags | JS_PROP_HAS_VALUE | diff --git a/test262_errors.txt b/test262_errors.txt index f4b5020..e0ff145 100644 --- a/test262_errors.txt +++ b/test262_errors.txt @@ -11,7 +11,6 @@ test262/test/language/expressions/compound-assignment/S11.13.2_A6.8_T1.js:24: Te test262/test/language/expressions/compound-assignment/S11.13.2_A6.9_T1.js:24: Test262Error: #1: innerX === 2. Actual: 1 test262/test/language/expressions/compound-assignment/S11.13.2_A6.10_T1.js:24: Test262Error: #1: innerX === 2. Actual: 5 test262/test/language/expressions/compound-assignment/S11.13.2_A6.11_T1.js:24: Test262Error: #1: innerX === 2. Actual: 5 -test262/test/language/module-code/namespace/internals/super-access-to-tdz-binding.js:32: Test262Error: Expected a ReferenceError but got a TypeError 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}"