Skip to content

Commit 814d43a

Browse files
authored
Make TypedArray constructor extensible (#1113)
Fixes: #1112
1 parent b079cf7 commit 814d43a

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

quickjs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57146,6 +57146,7 @@ void JS_AddIntrinsicTypedArrays(JSContext *ctx)
5714657146
js_typed_array_base_funcs,
5714757147
countof(js_typed_array_base_funcs));
5714857148
JS_SetConstructor(ctx, typed_array_base_func, typed_array_base_proto);
57149+
JS_SetConstructorBit(ctx, typed_array_base_func, true);
5714957150

5715057151
/* Used to squelch a -Wcast-function-type warning. */
5715157152
JSCFunctionType ft = { .generic_magic = js_typed_array_constructor };

tests/test_builtin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,16 @@ function test_typed_array()
569569
assert(a.buffer, b.buffer);
570570
assert(a.toString(), "0,0,0,255");
571571
assert(b.toString(), "0,0,255,255");
572+
573+
const TypedArray = class extends Object.getPrototypeOf(Uint8Array) {};
574+
let caught = false;
575+
try {
576+
new TypedArray(); // extensible but not instantiable
577+
} catch (e) {
578+
assert(/cannot be called/.test(e.message));
579+
caught = true;
580+
}
581+
assert(caught);
572582
}
573583

574584
function test_json()

0 commit comments

Comments
 (0)