aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-17 09:30:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-07-17 09:30:53 -0300
commit8bb272a3e3d0693a1d587cfa3469153978ae617f (patch)
treec3a87e37c1921fcd27433036b84e500e0dc6735f /ldebug.c
parentc229ed597f939eacfe1e9b7113e2a082fe93a3ae (diff)
downloadlua-8bb272a3e3d0693a1d587cfa3469153978ae617f.tar.gz
lua-8bb272a3e3d0693a1d587cfa3469153978ae617f.tar.bz2
lua-8bb272a3e3d0693a1d587cfa3469153978ae617f.zip
new conversion float->integer: conversion is valid only when
float has an exact representation as an integer
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ldebug.c b/ldebug.c
index 2c3c70f3..f7b2866e 100644
--- a/ldebug.c
+++ b/ldebug.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldebug.c,v 2.97 2013/12/09 14:21:10 roberto Exp roberto $ 2** $Id: ldebug.c,v 2.98 2014/07/15 21:26:50 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*/
@@ -534,18 +534,20 @@ l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) {
534 534
535l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { 535l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
536 lua_Number temp; 536 lua_Number temp;
537 if (!tonumber(p1, &temp)) 537 if (!tonumber(p1, &temp)) /* first operand is wrong? */
538 p2 = p1; /* first operand is wrong */ 538 p2 = p1; /* now second is wrong */
539 luaG_typeerror(L, p2, "perform arithmetic on"); 539 luaG_typeerror(L, p2, "perform arithmetic on");
540} 540}
541 541
542 542
543/*
544** Error when both values are convertible to numbers, but not to integers
545*/
543l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { 546l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) {
544 lua_Integer temp; 547 lua_Integer temp;
545 if (!tointeger(p1, &temp)) 548 if (!tointeger(p1, &temp))
546 p2 = p1; 549 p2 = p1;
547 luaG_runerror(L, "attempt to convert an out of range float%s to an integer", 550 luaG_runerror(L, "number%s has no integer representation", varinfo(L, p2));
548 varinfo(L, p2));
549} 551}
550 552
551 553