From: Fabrice Bellard Date: Tue, 29 Sep 2026 12:00:18 +0000 (+0200) Subject: fixed Function.prototype.bind prototype inheritance X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=efc48a319a96c35c9d44e1287c5be253515616fd;p=quickjs.git fixed Function.prototype.bind prototype inheritance --- diff --git a/quickjs.c b/quickjs.c index b0395d7..19c05ed 100644 --- a/quickjs.c +++ b/quickjs.c @@ -41494,15 +41494,19 @@ static JSValue js_function_bind(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv) { JSBoundFunction *bf; - JSValue func_obj, name1, len_val; + JSValue func_obj, name1, len_val, proto; JSObject *p; int arg_count, i, ret; if (check_function(ctx, this_val)) return JS_EXCEPTION; - func_obj = JS_NewObjectProtoClass(ctx, ctx->function_proto, + proto = JS_GetPrototype(ctx, this_val); + if (JS_IsException(proto)) + return JS_EXCEPTION; + func_obj = JS_NewObjectProtoClass(ctx, proto, JS_CLASS_BOUND_FUNCTION); + JS_FreeValue(ctx, proto); if (JS_IsException(func_obj)) return JS_EXCEPTION; p = JS_VALUE_GET_OBJ(func_obj); diff --git a/test262_errors.txt b/test262_errors.txt index 5f2b43c..47a07ea 100644 --- a/test262_errors.txt +++ b/test262_errors.txt @@ -16,7 +16,6 @@ test262/test/staging/sm/Function/constructor-binding.js:11: Test262Error: Expect test262/test/staging/sm/Function/function-bind.js:24: Test262Error: Conforms to NativeFunction Syntax: "function bound unbound() {\n [native code]\n}" test262/test/staging/sm/Function/implicit-this-in-parameter-expression.js:12: Test262Error: Expected SameValue(«[object Object]», «undefined») to be true test262/test/staging/sm/Function/invalid-parameter-list.js:13: Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all -test262/test/staging/sm/class/boundFunctionSubclassing.js:9: Test262Error: Expected SameValue(«false», «true») to be true test262/test/staging/sm/class/strictExecution.js:13: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all test262/test/staging/sm/class/superPropOrdering.js:17: Test262Error: Expected a TypeError to be thrown but no exception was thrown at all test262/test/staging/sm/lexical-environment/block-scoped-functions-annex-b-arguments.js:13: Test262Error: Expected SameValue(«"object"», «"function"») to be true