]> git.kaiwu.me - quickjs.git/commitdiff
Make BigInt64Array.prototype.with() throw TypeError instead of RangeError when value...
authorFabrice Bellard <fabrice@bellard.org>
Tue, 24 Nov 2026 16:47:24 +0000 (17:47 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Tue, 24 Nov 2026 16:47:24 +0000 (17:47 +0100)
quickjs.c

index e5cbaf04df054d2559cb9c38894ee832a8f973bf..9b5dd551258c92b5bab4f37e29696d3243a6da69 100644 (file)
--- a/quickjs.c
+++ b/quickjs.c
@@ -61865,7 +61865,11 @@ static JSValue js_typed_array_with(JSContext *ctx, JSValueConst this_val,
     if (idx < 0)
         idx = len + idx;
 
-    val = JS_ToPrimitive(ctx, argv[1], JS_HINT_NUMBER);
+    if (p->class_id == JS_CLASS_BIG_INT64_ARRAY || p->class_id == JS_CLASS_BIG_UINT64_ARRAY) {
+        val = JS_ToBigInt(ctx, argv[1]);
+    } else {
+        val = JS_ToNumber(ctx, argv[1]);
+    }
     if (JS_IsException(val))
         return JS_EXCEPTION;