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

Error PANIC attempt to call a nil value (global 'unpack'))

dooleydiligent opened this issue · comments

I work in typescript
My script is

   const code = 'return unpack({"one", "two", "three"})';
    const L: any = lauxlib.luaL_newstate();
    lualib.luaL_openlibs(L);
    const loadStatus = lauxlib.luaL_loadstring(L, fengari.to_luastring(`${code}`));
    if (loadStatus !== lua.LUA_OK)  {
     // fail
    }
    lua.lua_call(L, 0, lua.LUA_MULTRET);

I expect to see the 'one' value returned but instead I get the subject PANIC.
fengari@0.1.4

Must I explicitly set pack/unpack and others to global?

Anyone can help?

Fengari implements Lua 5.3: unpack is table.unpack.

Thanks. resolved