The typeof operator should return 'function' for callable objects.

This commit is contained in:
Tor Andersson
2014-02-05 05:46:23 +01:00
parent 6ecb4e7a4e
commit f0c795771d
+6 -2
View File
@@ -147,13 +147,17 @@ int js_isuserdata(js_State *J, const char *tag, int idx)
static const char *js_typeof(js_State *J, int idx)
{
switch (stackidx(J, idx)->type) {
const js_Value *v = stackidx(J, idx);
switch (v->type) {
case JS_TUNDEFINED: return "undefined";
case JS_TNULL: return "object";
case JS_TBOOLEAN: return "boolean";
case JS_TNUMBER: return "number";
case JS_TSTRING: return "string";
case JS_TOBJECT: return "object";
case JS_TOBJECT:
if (v->u.object->type == JS_CFUNCTION || v->u.object->type == JS_CCFUNCTION)
return "function";
return "object";
}
return "object";
}