shithub: libmujs

Download patch

ref: 05c2ee9e519acc69c991cb9ee6173afa4dfcc8e9
parent: cb6facdf9ccf7f39c5689e6b8e5366b63d984df0
author: Tor Andersson <tor.andersson@artifex.com>
date: Thu Jan 8 09:28:10 EST 2015

Use last resort '[object]' ToPrimitive rather than throwing an error.

Helps to print objects without a toString method, like the global object
and objects created without a prototype.

--- a/jsvalue.c
+++ b/jsvalue.c
@@ -107,7 +107,9 @@
 		}
 	}
 
-	js_typeerror(J, "cannot convert object to primitive");
+	v->type = JS_TLITSTR;
+	v->u.litstr = "[object]";
+	return;
 }
 
 /* ToBoolean() on a value */