dynamiclua icon indicating copy to clipboard operation
dynamiclua copied to clipboard

Using a table as __index in metatable does not work

Open nrother opened this issue 11 years ago • 0 comments

Lua allows the metatables __index entry to be a table (and not only a function). In this case the value from the __index table is returned, if found. See http://www.lua.org/pil/13.4.1.html

With this contruct a request to any table entry from C# fails. Proof:

dynamic mt = lua.NewTable("mt");
mt.__index = lua("return { a = 5 }");
dynamic tab = lua.NewTable("tab");
tab.a = 4;
tab.SetMetatable(mt);
Console.WriteLine(tab.a); //crash

nrother avatar Mar 04 '14 09:03 nrother