History

Issue 95: Improve error message when trying to call a non-callable.

Tor Andersson committed 7 years ago

Commit ffe0ca71 parent 5de1f973 files · +5 −4Browse files

Unified · Split

3 files
  1. jsdate.c +1 −1
  2. jsrun.c +3 −3
  3. mujs.h +1 −0
jsdate.c+1−1
@@ -741,7 +741,7 @@ static void Dp_toJSON(js_State *J) · 740 unmodified lines
741 741
742 js_getproperty(J, 0, "toISOString");742 js_getproperty(J, 0, "toISOString");
743 if (!js_iscallable(J, -1))743 if (!js_iscallable(J, -1))
744 js_typeerror(J, "Date.prototype.toJSON: this.toISOString not a function");744 js_typeerror(J, "this.toISOString is not a function");
745 js_copy(J, 0);745 js_copy(J, 0);
746 js_call(J, 0);746 js_call(J, 0);
747}747}
jsrun.c+3−3
@@ -230,7 +230,7 @@ int js_iserror(js_State *J, int idx) · 229 unmodified lines
230 return v->type == JS_TOBJECT && v->u.object->type == JS_CERROR;230 return v->type == JS_TOBJECT && v->u.object->type == JS_CERROR;
231}231}
232 232
233static const char *js_typeof(js_State *J, int idx)233const char *js_typeof(js_State *J, int idx)
234{234{
235 js_Value *v = stackidx(J, idx);235 js_Value *v = stackidx(J, idx);
236 switch (v->type) {236 switch (v->type) {
@@ -1056,7 +1056,7 @@ void js_call(js_State *J, int n) · 819 unmodified lines
1056 int savebot;1056 int savebot;
1057 1057
1058 if (!js_iscallable(J, -n-2))1058 if (!js_iscallable(J, -n-2))
1059 js_typeerror(J, "called object is not a function");1059 js_typeerror(J, "%s is not callable", js_typeof(J, -n-2));
1060 1060
1061 obj = js_toobject(J, -n-2);1061 obj = js_toobject(J, -n-2);
1062 1062
@@ -1090,7 +1090,7 @@ void js_construct(js_State *J, int n) · 27 unmodified lines
1090 js_Object *newobj;1090 js_Object *newobj;
1091 1091
1092 if (!js_iscallable(J, -n-1))1092 if (!js_iscallable(J, -n-1))
1093 js_typeerror(J, "called object is not a function");1093 js_typeerror(J, "%s is not callable", js_typeof(J, -n-1));
1094 1094
1095 obj = js_toobject(J, -n-1);1095 obj = js_toobject(J, -n-1);
1096 1096
mujs.h+1−0
@@ -213,6 +213,7 @@ int js_compare(js_State *J, int *okay); · 212 unmodified lines
213int js_equal(js_State *J);213int js_equal(js_State *J);
214int js_strictequal(js_State *J);214int js_strictequal(js_State *J);
215int js_instanceof(js_State *J);215int js_instanceof(js_State *J);
216const char *js_typeof(js_State *J, int idx);
216 217
217#ifdef __cplusplus218#ifdef __cplusplus
218}219}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t