- edited description
next differs from its Lua equivalent when using table with both list and map entries
Issue #50
resolved
Take the following script:
table = { key='value', 42, [123]=321 }
for _=1,2 do
print('→ ', i, '->', v)
i,v = next(table, i)
print('← ', i, '->', v)
end
i,v = next(table, i)
print(i, '->', v)
In standard Lua, this should output something similar to this:
→ nil -> nil
← 1 -> 42
→ 1 -> 42
← key -> value
123 -> 321
However, in MobTalkerScript, the following output is produced:
→ nil -> nil
← 1 -> 42
→ 1 -> 42
← nil -> nil
1 -> 42
Apparently, next
only iterates list indices but leaves out any remaining map indices. This behaviour is critically different from Lua and will cause incompatibilities without any reasonable workarounds (well, apart from reimplementing next
yourself).
Comments (3)
-
reporter -
reporter - changed milestone to 3.0.7
-
reporter - changed status to resolved
Fix MtsTable.getNext(MtsValue) to pass the tests (fixes
#50)Minor adjustments for MtsTableList, out-of-bounds indexes now throw an IndexOutOfBoundsException instead of an ArrayIndexOutOfBoundsException
Deduplicated code
→ <<cset 77cb256afdfb>>
- Log in to comment