@@ -7129,6 +7129,11 @@ static JSValue JS_ThrowStackOverflow(JSContext *ctx)
7129
7129
return JS_ThrowRangeError(ctx, "Maximum call stack size exceeded");
7130
7130
}
7131
7131
7132
+ static JSValue JS_ThrowTypeErrorNotAFunction(JSContext *ctx)
7133
+ {
7134
+ return JS_ThrowTypeError(ctx, "not a function");
7135
+ }
7136
+
7132
7137
static JSValue JS_ThrowTypeErrorNotAnObject(JSContext *ctx)
7133
7138
{
7134
7139
return JS_ThrowTypeError(ctx, "not an object");
@@ -15045,7 +15050,7 @@ static JSValue JS_CallInternal(JSContext *caller_ctx, JSValue func_obj,
15045
15050
call_func = rt->class_array[p->class_id].call;
15046
15051
if (!call_func) {
15047
15052
not_a_function:
15048
- return JS_ThrowTypeError (caller_ctx, "not a function" );
15053
+ return JS_ThrowTypeErrorNotAFunction (caller_ctx);
15049
15054
}
15050
15055
return call_func(caller_ctx, func_obj, this_obj, argc,
15051
15056
argv, flags);
@@ -17685,7 +17690,7 @@ static JSValue JS_CallConstructorInternal(JSContext *ctx,
17685
17690
call_func = ctx->rt->class_array[p->class_id].call;
17686
17691
if (!call_func) {
17687
17692
not_a_function:
17688
- return JS_ThrowTypeError (ctx, "not a function" );
17693
+ return JS_ThrowTypeErrorNotAFunction (ctx);
17689
17694
}
17690
17695
return call_func(ctx, func_obj, new_target, argc,
17691
17696
argv, flags);
@@ -36063,7 +36068,7 @@ static int check_function(JSContext *ctx, JSValue obj)
36063
36068
{
36064
36069
if (likely(JS_IsFunction(ctx, obj)))
36065
36070
return 0;
36066
- JS_ThrowTypeError (ctx, "not a function" );
36071
+ JS_ThrowTypeErrorNotAFunction (ctx);
36067
36072
return -1;
36068
36073
}
36069
36074
@@ -40094,7 +40099,7 @@ static JSValue js_array_toSorted(JSContext *ctx, JSValue this_val,
40094
40099
40095
40100
ok = JS_IsUndefined(argv[0]) || JS_IsFunction(ctx, argv[0]);
40096
40101
if (!ok)
40097
- return JS_ThrowTypeError (ctx, "not a function" );
40102
+ return JS_ThrowTypeErrorNotAFunction (ctx);
40098
40103
40099
40104
ret = JS_EXCEPTION;
40100
40105
arr = JS_UNDEFINED;
@@ -46844,7 +46849,7 @@ static JSValue js_proxy_call(JSContext *ctx, JSValue func_obj,
46844
46849
return JS_EXCEPTION;
46845
46850
if (!s->is_func) {
46846
46851
JS_FreeValue(ctx, method);
46847
- return JS_ThrowTypeError (ctx, "not a function" );
46852
+ return JS_ThrowTypeErrorNotAFunction (ctx);
46848
46853
}
46849
46854
if (JS_IsUndefined(method))
46850
46855
return JS_Call(ctx, s->target, this_obj, argc, argv);
0 commit comments