mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Issue 95: Improve error message when trying to call a non-callable.
This commit is contained in:
2
jsdate.c
2
jsdate.c
@@ -741,7 +741,7 @@ static void Dp_toJSON(js_State *J)
|
||||
|
||||
js_getproperty(J, 0, "toISOString");
|
||||
if (!js_iscallable(J, -1))
|
||||
js_typeerror(J, "Date.prototype.toJSON: this.toISOString not a function");
|
||||
js_typeerror(J, "this.toISOString is not a function");
|
||||
js_copy(J, 0);
|
||||
js_call(J, 0);
|
||||
}
|
||||
|
||||
6
jsrun.c
6
jsrun.c
@@ -230,7 +230,7 @@ int js_iserror(js_State *J, int idx)
|
||||
return v->type == JS_TOBJECT && v->u.object->type == JS_CERROR;
|
||||
}
|
||||
|
||||
static const char *js_typeof(js_State *J, int idx)
|
||||
const char *js_typeof(js_State *J, int idx)
|
||||
{
|
||||
js_Value *v = stackidx(J, idx);
|
||||
switch (v->type) {
|
||||
@@ -1056,7 +1056,7 @@ void js_call(js_State *J, int n)
|
||||
int savebot;
|
||||
|
||||
if (!js_iscallable(J, -n-2))
|
||||
js_typeerror(J, "called object is not a function");
|
||||
js_typeerror(J, "%s is not callable", js_typeof(J, -n-2));
|
||||
|
||||
obj = js_toobject(J, -n-2);
|
||||
|
||||
@@ -1090,7 +1090,7 @@ void js_construct(js_State *J, int n)
|
||||
js_Object *newobj;
|
||||
|
||||
if (!js_iscallable(J, -n-1))
|
||||
js_typeerror(J, "called object is not a function");
|
||||
js_typeerror(J, "%s is not callable", js_typeof(J, -n-1));
|
||||
|
||||
obj = js_toobject(J, -n-1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user