aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-05-06 14:21:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-05-06 14:21:59 -0300
commitf2043b7a589448990199f246a362c3df648157c7 (patch)
treef5e27b9ea2dfbf8791c5cef072f2643daed5a706 /ldebug.c
parent2b1c2c61b025aa06446367965316b3878578a768 (diff)
downloadlua-f2043b7a589448990199f246a362c3df648157c7.tar.gz
lua-f2043b7a589448990199f246a362c3df648157c7.tar.bz2
lua-f2043b7a589448990199f246a362c3df648157c7.zip
correct error message for conversion errors from float to int
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/ldebug.c b/ldebug.c
index fa7bbd96..b729563b 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.93 2013/04/26 16:03:50 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.94 2013/04/29 16:58:10 roberto Exp roberto $
3** Debug Interface 3** Debug Interface
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -498,10 +498,9 @@ static const char *getupvalname (CallInfo *ci, const TValue *o,
498} 498}
499 499
500 500
501l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { 501static const char *varinfo (lua_State *L, const TValue *o) {
502 const char *name;
502 CallInfo *ci = L->ci; 503 CallInfo *ci = L->ci;
503 const char *name = NULL;
504 const char *t = objtypename(o);
505 const char *kind = NULL; 504 const char *kind = NULL;
506 if (isLua(ci)) { 505 if (isLua(ci)) {
507 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ 506 kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */
@@ -509,17 +508,19 @@ l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
509 kind = getobjname(ci_func(ci)->p, currentpc(ci), 508 kind = getobjname(ci_func(ci)->p, currentpc(ci),
510 cast_int(o - ci->u.l.base), &name); 509 cast_int(o - ci->u.l.base), &name);
511 } 510 }
512 if (kind) 511 return (kind) ? luaO_pushfstring(L, " (%s " LUA_QS ")", kind, name) : "";
513 luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", 512}
514 op, kind, name, t); 513
515 else 514
516 luaG_runerror(L, "attempt to %s a %s value", op, t); 515l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
516 const char *t = objtypename(o);
517 luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o));
517} 518}
518 519
519 520
520l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { 521l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) {
521 if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; 522 if (ttisstring(p1) || ttisnumber(p1)) p1 = p2;
522 lua_assert(!ttisstring(p1) && !ttisnumber(p2)); 523 lua_assert(!ttisstring(p1) && !ttisnumber(p1));
523 luaG_typeerror(L, p1, "concatenate"); 524 luaG_typeerror(L, p1, "concatenate");
524} 525}
525 526
@@ -532,6 +533,15 @@ l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
532} 533}
533 534
534 535
536l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) {
537 lua_Integer temp;
538 if (!tointeger(p1, &temp))
539 p2 = p1;
540 luaG_runerror(L, "attempt to convert an out of range float%s to an integer",
541 varinfo(L, p2));
542}
543
544
535l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { 545l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
536 const char *t1 = objtypename(p1); 546 const char *t1 = objtypename(p1);
537 const char *t2 = objtypename(p2); 547 const char *t2 = objtypename(p2);