stipsan / ioredis-mock

Emulates ioredis by performing all operations in-memory.
MIT License
336 stars 125 forks source link

Return table from lua will fail with exception #1108

Open artur-ma opened 2 years ago

artur-ma commented 2 years ago

Lua:

local a = {}
table.insert(a, 1)
table.insert(a, 2)

return a

Will raise exception

/test/node_modules/fengari/src/lapi.js:332
        L.stack[L.top] = new TValue(LUA_TLCF, fn);
                       ^

TypeError: Cannot set properties of null (setting '2')
    at lua_pushcclosure (/workspace/test/node_modules/fengari/src/lapi.js:332:24)
    at lua_pushcfunction (/workspace/test/node_modules/fengari/src/lapi.js:351:5)
    at tostring (workspace/test/node_modules/fengari-interop/src/js.js:376:2)
    at Function.js_proxy.toString (workspace/test/node_modules/fengari-interop/src/js.js:482:10)
    at formatValue (node:internal/util/inspect:763:19)
    at inspect (node:internal/util/inspect:340:10)
    at formatWithOptionsInternal (node:internal/util/inspect:2006:40)
    at formatWithOptions (node:internal/util/inspect:1888:10)
    at console.value (node:internal/console/constructor:323:14)
    at console.log (node:internal/console/constructor:359:61)

ioredis result:

[ 1, 2 ]

The funny part, is that if table contains only one element it will work!

local a = {}
table.insert(a, 1)

return a

ioredis-mock result:

[ 1 ]
thongxuan commented 1 year ago

same here!