From 05fb3d9dc89e9fe1237eced469be1ca150990f80 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 29 Dec 2023 15:10:45 +0100 Subject: [PATCH] Fix Reflect with detached ArrayBuffer (#239) --- quickjs.c | 10 +++++----- test262_errors.txt | 8 -------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/quickjs.c b/quickjs.c index 4e4a5cd..0da6098 100644 --- a/quickjs.c +++ b/quickjs.c @@ -8730,7 +8730,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj, ta_out_of_bound: if (typed_array_is_detached(ctx, p)) if (!(flags & JS_PROP_DEFINE_PROPERTY)) - return FALSE; // per spec: no OOB exception + return TRUE; // per spec: no OOB exception return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index"); } p->u.array.u.double_ptr[idx] = d; @@ -34586,8 +34586,7 @@ static __exception int JS_DefinePropertyDesc(JSContext *ctx, JSValue obj, return -1; ret = JS_DefineProperty(ctx, obj, prop, - d.value, d.getter, d.setter, - d.flags | flags | JS_PROP_DEFINE_PROPERTY); + d.value, d.getter, d.setter, d.flags | flags); js_free_desc(ctx, &d); return ret; } @@ -34618,7 +34617,8 @@ static __exception int JS_ObjectDefineProperties(JSContext *ctx, desc = JS_GetProperty(ctx, props, atoms[i].atom); if (JS_IsException(desc)) goto exception; - if (JS_DefinePropertyDesc(ctx, obj, atoms[i].atom, desc, JS_PROP_THROW) < 0) + if (JS_DefinePropertyDesc(ctx, obj, atoms[i].atom, desc, + JS_PROP_THROW | JS_PROP_DEFINE_PROPERTY) < 0) goto exception; } ret = 0; @@ -34720,7 +34720,7 @@ static JSValue js_object_defineProperty(JSContext *ctx, JSValue this_val, return JS_EXCEPTION; flags = 0; if (!magic) - flags |= JS_PROP_THROW; + flags = JS_PROP_THROW | JS_PROP_DEFINE_PROPERTY; ret = JS_DefinePropertyDesc(ctx, obj, atom, desc, flags); JS_FreeAtom(ctx, atom); if (ret < 0) { diff --git a/test262_errors.txt b/test262_errors.txt index ae95702..961dbcf 100644 --- a/test262_errors.txt +++ b/test262_errors.txt @@ -3,16 +3,8 @@ test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Er test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: strict mode: Test262Error: Expected [a, abc] and [a, undefined] to have the same contents. ? quantifier test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: Test262Error: (Testing with BigInt64Array.) test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: strict mode: Test262Error: (Testing with BigInt64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js:40: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/tonumber-value-detached-buffer.js:40: strict mode: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42n;}}}) must return true Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.) test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: Test262Error: (Testing with Float64Array.) test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: strict mode: Test262Error: (Testing with Float64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js:42: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42;}}} ) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/tonumber-value-detached-buffer.js:42: strict mode: Test262Error: Reflect.defineProperty(ta, 0, {value: {valueOf() {$DETACHBUFFER(ta.buffer); return 42;}}} ) must return true Expected SameValue(«false», «true») to be true (Testing with Float64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-detached-buffer.js:24: Test262Error: Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/Set/BigInt/tonumber-value-detached-buffer.js:24: strict mode: Test262Error: Expected SameValue(«false», «true») to be true (Testing with BigInt64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js:39: Test262Error: Expected SameValue(«false», «true») to be true (Testing with Float64Array.) -test262/test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js:39: strict mode: Test262Error: Expected SameValue(«false», «true») to be true (Testing with Float64Array.) test262/test/language/expressions/arrow-function/static-init-await-reference.js:12: unexpected error type: Test262: This statement should not be evaluated. test262/test/language/expressions/arrow-function/static-init-await-reference.js:12: strict mode: unexpected error type: Test262: This statement should not be evaluated. test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError