Page 1 of 1

Lua lied to me :(

Posted: Fri Jul 12, 2013 6:21 am
by LuaWeaver
Well, this happened.

Code: Select all

for i=1,nil do end
That errors, of course:
>'for' limit must be a number

So I go and do this:

Code: Select all

for i=1,0/0 do end
That doesn't error! Now, go:

Code: Select all

print(0/0) --> -nan
nan is not a number, so why is for letting me use it as a limit? :death:

Re: Lua lied to me :(

Posted: Fri Jul 12, 2013 7:07 am
by slime
LuaWeaver wrote:nan is not a number, so why is for letting me use it as a limit? :death:
Ah, but it is! :)

Code: Select all

print(type(0/0))
http://en.wikipedia.org/wiki/NaN#Encoding

Re: Lua lied to me :(

Posted: Fri Jul 12, 2013 2:32 pm
by raidho36
Reminds me of:
> issue #666: LÖVE crashes when I try to crash it.

Re: Lua lied to me :(

Posted: Fri Jul 12, 2013 6:52 pm
by T-Bone
I've never thought of this before. It's kind of like Wine except even more obvious :)

Re: Lua lied to me :(

Posted: Fri Jul 12, 2013 6:57 pm
by Xgoff
ieee probably should have called it something else, like "not representable" or something :(

reminds me of a past thread on the lua mailing list where someone suggested lua expressions that would have resulted in nan should return nil instead, because "not a number". NOPE.