fengari-lua / fengari

🌙 φεγγάρι - The Lua VM written in JS ES6 for Node and the browser

Home Page:https://fengari.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong value from luaH_getn

unkernet opened this issue · comments

There is difference between fengari and Lua 5.3:

local t = {1, nil, 3, 4}
print(#t) -- 1 (4 in Lua 5.3)
local t = {nil, nil, 3, 4, 5, 6, 7, 8}
print(#t) -- 6 Why?

According to the Lua 5.3 documentation

When t is not a sequence, #t can return any of its borders.

Fengari's implementation of the table is different from PUC Rio, but I think both results are valid under the manual's definition.

local t = {nil, nil, 3, 4, 5, 6, 7, 8}
print(#t) -- 6 Why?

That's a bug. It should be 0 or 8.

Please review the fix in #163

Looks good