Skip to content

Commit 05fb3d9

Browse files
authored
Fix Reflect with detached ArrayBuffer (#239)
1 parent 64c9ac5 commit 05fb3d9

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

quickjs.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8730,7 +8730,7 @@ static int JS_SetPropertyValue(JSContext *ctx, JSValue this_obj,
87308730
ta_out_of_bound:
87318731
if (typed_array_is_detached(ctx, p))
87328732
if (!(flags & JS_PROP_DEFINE_PROPERTY))
8733-
return FALSE; // per spec: no OOB exception
8733+
return TRUE; // per spec: no OOB exception
87348734
return JS_ThrowTypeErrorOrFalse(ctx, flags, "out-of-bound numeric index");
87358735
}
87368736
p->u.array.u.double_ptr[idx] = d;
@@ -34586,8 +34586,7 @@ static __exception int JS_DefinePropertyDesc(JSContext *ctx, JSValue obj,
3458634586
return -1;
3458734587

3458834588
ret = JS_DefineProperty(ctx, obj, prop,
34589-
d.value, d.getter, d.setter,
34590-
d.flags | flags | JS_PROP_DEFINE_PROPERTY);
34589+
d.value, d.getter, d.setter, d.flags | flags);
3459134590
js_free_desc(ctx, &d);
3459234591
return ret;
3459334592
}
@@ -34618,7 +34617,8 @@ static __exception int JS_ObjectDefineProperties(JSContext *ctx,
3461834617
desc = JS_GetProperty(ctx, props, atoms[i].atom);
3461934618
if (JS_IsException(desc))
3462034619
goto exception;
34621-
if (JS_DefinePropertyDesc(ctx, obj, atoms[i].atom, desc, JS_PROP_THROW) < 0)
34620+
if (JS_DefinePropertyDesc(ctx, obj, atoms[i].atom, desc,
34621+
JS_PROP_THROW | JS_PROP_DEFINE_PROPERTY) < 0)
3462234622
goto exception;
3462334623
}
3462434624
ret = 0;
@@ -34720,7 +34720,7 @@ static JSValue js_object_defineProperty(JSContext *ctx, JSValue this_val,
3472034720
return JS_EXCEPTION;
3472134721
flags = 0;
3472234722
if (!magic)
34723-
flags |= JS_PROP_THROW;
34723+
flags = JS_PROP_THROW | JS_PROP_DEFINE_PROPERTY;
3472434724
ret = JS_DefinePropertyDesc(ctx, obj, atom, desc, flags);
3472534725
JS_FreeAtom(ctx, atom);
3472634726
if (ret < 0) {

test262_errors.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,8 @@ test262/test/built-ins/RegExp/lookahead-quantifier-match-groups.js:27: Test262Er
33
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
44
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: Test262Error: (Testing with BigInt64Array.)
55
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/BigInt/detached-buffer.js:46: strict mode: Test262Error: (Testing with BigInt64Array.)
6-
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.)
7-
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.)
86
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: Test262Error: (Testing with Float64Array.)
97
test262/test/built-ins/TypedArrayConstructors/internals/DefineOwnProperty/detached-buffer.js:47: strict mode: Test262Error: (Testing with Float64Array.)
10-
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.)
11-
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.)
12-
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.)
13-
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.)
14-
test262/test/built-ins/TypedArrayConstructors/internals/Set/tonumber-value-detached-buffer.js:39: Test262Error: Expected SameValue(«false», «true») to be true (Testing with Float64Array.)
15-
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.)
168
test262/test/language/expressions/arrow-function/static-init-await-reference.js:12: unexpected error type: Test262: This statement should not be evaluated.
179
test262/test/language/expressions/arrow-function/static-init-await-reference.js:12: strict mode: unexpected error type: Test262: This statement should not be evaluated.
1810
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: Test262Error: Expected a DummyError but got a TypeError

0 commit comments

Comments
 (0)