diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-17 09:30:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-07-17 09:30:53 -0300 |
commit | 8bb272a3e3d0693a1d587cfa3469153978ae617f (patch) | |
tree | c3a87e37c1921fcd27433036b84e500e0dc6735f /ldebug.c | |
parent | c229ed597f939eacfe1e9b7113e2a082fe93a3ae (diff) | |
download | lua-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.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -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 | ||
535 | l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { | 535 | l_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 | */ | ||
543 | l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { | 546 | l_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 | ||