From 0467057b64fab4083f1fdef3dc44b0c2815e9d9c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sun, 19 Jan 2014 15:45:29 +0100 Subject: [PATCH] Use ECMA-262 r5 semantics for missing this argument to call/apply. --- jsbfunction.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) 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);