krka/kahlua2 — Issue #8: ipairs() fails when tables contain 'false'
Author: haesemaths
Created: 2011-11-30 02:40:55+00:00
State: open

There is a bug in the standard library implementation of ipairs that causes it to stop prematurely when it finds a false value in a table.

For example:

````lua
tbl = { 1, 2, false, 3 }
for i, v in ipairs(tbl) do
print(i, v)
end

-- In Kahlua, this produces:
-- 1 1
-- 2 2
--
-- Whereas, standard Lua gives:
-- 1 1
-- 2 2
-- 3 false
-- 4 3
````

There is an easy fix for this. The relevant function is `ipairs_iterator` defined in `core/resources/stdlib.lua`. Changing the line (number 14) that reads:

````lua
if nextValue then
````

to:

````lua
if nextValue == false then
````

should do the trick.