lua-users home
lua-l archive

Lua 5.3: wrong coercion?

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi all!
I just found something that seems odd in Lua 5.3.
According to sect 3.4.3 in the refman:
"The conversion from strings to numbers goes as follows: First, the string is converted to an integer or a float, following its syntax and the rules of the Lua lexer. (The string may have also leading and trailing spaces and a sign.) Then, the resulting number is converted to the required type (float or integer) according to the previous rules." Thus if I have a string which is "42" it should be coerced to an integer, since 42 is parsed as an integer constant by the lexer, whereas I get:
print( 43, "42" + 1 ) --> 43 43.0
where it seems that the addition is a float addition, signaling that one of the operands is float. Is this a bug, an error in the refman or maybe something on my side (Windows 7-64, using 32bit executables compiled with TDM-GCC 4.9.2 32 bit)? Am I missing something?
-- Lorenzo

AltStyle によって変換されたページ (->オリジナル) /