lua-users home
lua-l archive

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


Lua 5.4 changed the semantics of integer for loops to end the loop in
the case of overflow. This means that a construct like "'for i=1,#t"
will always work, even if #t is the maximum integer. The ipairs
iterator function doesn't have similar semantics, instead when the
second argument to the iterator function is the maximum integer it
will overflow and cause undefined behavior.

Example:
print(ipairs{}({[math.mininteger]=1},math.maxinteger))

Following the semantics of the integer for loop, I think it would make
the most sense to return nil in the case of the second argument being
the maximum integer, instead of overflowing and causing undefined
behavior.