Fix Reflect with detached ArrayBuffer (#239)

This commit is contained in:
Ben Noordhuis 2023-12-29 15:10:45 +01:00 committed by GitHub
parent 64c9ac5392
commit 05fb3d9dc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 13 deletions

View file

@ -8730,7 +8730,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj,
ta_out_of_bound: ta_out_of_bound:
if (typed_array_is_detached(ctx, p)) if (typed_array_is_detached(ctx, p))
if (!(flags & JS_PROP_DEFINE_PROPERTY)) 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"); return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index");
} }
p->u.array.u.double_ptr[idx] = d; p->u.array.u.double_ptr[idx] = d;
@ -34586,8 +34586,7 @@ static __exception int JS_DefinePropertyDesc(JSContext *ctx, JSValue obj,
return -1; return -1;
ret = JS_DefineProperty(ctx, obj, prop, ret = JS_DefineProperty(ctx, obj, prop,
d.value, d.getter, d.setter, d.value, d.getter, d.setter, d.flags | flags);
d.flags | flags | JS_PROP_DEFINE_PROPERTY);
js_free_desc(ctx, &d); js_free_desc(ctx, &d);
return ret; return ret;
} }
@ -34618,7 +34617,8 @@ static __exception int JS_ObjectDefineProperties(JSContext *ctx,
desc = JS_GetProperty(ctx, props, atoms[i].atom); desc = JS_GetProperty(ctx, props, atoms[i].atom);
if (JS_IsException(desc)) if (JS_IsException(desc))
goto exception; 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; goto exception;
} }
ret = 0; ret = 0;
@ -34720,7 +34720,7 @@ static JSValue js_object_defineProperty(JSContext *ctx, JSValue this_val,
return JS_EXCEPTION; return JS_EXCEPTION;
flags = 0; flags = 0;
if (!magic) if (!magic)
flags |= JS_PROP_THROW; flags = JS_PROP_THROW | JS_PROP_DEFINE_PROPERTY;
ret = JS_DefinePropertyDesc(ctx, obj, atom, desc, flags); ret = JS_DefinePropertyDesc(ctx, obj, atom, desc, flags);
JS_FreeAtom(ctx, atom); JS_FreeAtom(ctx, atom);
if (ret < 0) { if (ret < 0) {

View file

@ -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/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: 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/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: 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/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: 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/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 test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError