shithub: libmujs

Download patch

ref: 0467057b64fab4083f1fdef3dc44b0c2815e9d9c
parent: 58421f16017721fd155fb471e28c3044ffe01aee
author: Tor Andersson <[email protected]>
date: Sun Jan 19 10:45:29 EST 2014

Use ECMA-262 r5 semantics for missing this argument to call/apply.

--- a/jsbfunction.c
+++ b/jsbfunction.c
@@ -52,14 +52,11 @@
 	char name[20];
 
 	if (!js_iscallable(J, 0))
-		jsR_error(J, "TypeError");
+		jsR_error(J, "TypeError: not a function");
+
 	js_copy(J, 0);
+	js_copy(J, 1);
 
-	if (js_isundefined(J, 1) || js_isnull(J, 1))
-		js_pushglobal(J);
-	else
-		js_copy(J, 1);
-
 	js_getproperty(J, 2, "length");
 	argc = js_tonumber(J, -1);
 	js_pop(J, 1);
@@ -78,13 +75,10 @@
 	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);