lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Alex Evans wrote:
> If I comment out the check (line 107 of lbaselib.c, luaL_checktype(L, 1,
> LUA_TTABLE);), all seems to work as expected and the metatable is set
> correctly.
> Is this a correct fix, or have I misunderstood the problem?

This is intentional behaviour. 'Regular' Lua programs should not
be able to change the behaviour of a whole type class. This is
just a bit too dangerous (of course for 'real' sandboxing you need
to do much more than the simple checks in the base libraries).

To change internal behaviour use the debug library. In particular
look for debug.setmetatable(). This works for all types (userdata, too).

BTW: I'm away for 10 days now and won't reply before I come back.