mherkender / lua.js

An ECMAscript framework to compile and run Lua code, allowing Lua to run in a browser or in Flash
http://blog.brokenfunction.com/
600 stars 73 forks source link

Table corruption when changing arraystate. #8

Closed jimbauwens closed 12 years ago

jimbauwens commented 12 years ago

In strange cases 'i' is a string. i + 1 becomes a string operation, and doesn't work as expected.

This causes tables to get corrupted.

Example lua script that suffers from this:

a = {1,2,3,4,5,6,7,8,9} a[1] = 1337

for i=1, 9 do print(a[i]) end

This will print 1337 null null null null null ..

mherkender commented 12 years ago

Thanks for the report, the bug has been fixed in f59409c88bdcf9b38964f2cdbeff1c158a6a65a5. I went with a slightly different solution for code size reasons, but the suggested fix was helpful, thanks again.