diff --git a/jsbfunction.c b/jsbfunction.c index 1331888..2a3e603 100644 --- a/jsbfunction.c +++ b/jsbfunction.c @@ -52,13 +52,10 @@ static int Fp_apply(js_State *J, int n) char name[20]; if (!js_iscallable(J, 0)) - jsR_error(J, "TypeError"); - js_copy(J, 0); + jsR_error(J, "TypeError: not a function"); - if (js_isundefined(J, 1) || js_isnull(J, 1)) - js_pushglobal(J); - else - js_copy(J, 1); + js_copy(J, 0); + js_copy(J, 1); js_getproperty(J, 2, "length"); argc = js_tonumber(J, -1); @@ -78,13 +75,10 @@ static int Fp_call(js_State *J, int n) int i; if (!js_iscallable(J, 0)) - jsR_error(J, "TypeError"); - js_copy(J, 0); + jsR_error(J, "TypeError: not a function"); - if (js_isundefined(J, 1) || js_isnull(J, 1)) - js_pushglobal(J); - else - js_copy(J, 1); + js_copy(J, 0); + js_copy(J, 1); for (i = 1; i < n; ++i) js_copy(J, i + 1);