Version: 0.4.2 AND 0.5-dev (cloned branch)
Issue: Assigning a value to a table with a metatable containing a __newindex function causes the table reference to become nil. If __newindex is a table or nil then there are no issues.
Runnable C# MVCE:
try
{
var luaState = LuaState.Create();
luaState.OpenBasicLibrary();
await luaState.DoStringAsync("""
local tbl = setmetatable({}, { __newindex = function() end })
print(tbl)
tbl.value = 0
print(tbl)
""");
}
catch (LuaRuntimeException e)
{
// ...
}
Reproducible Lua code:
local tbl = setmetatable({}, { __newindex = function() end })
print(tbl) -- table: <hash>
tbl.value = 0
print(tbl) -- nil
Without __newindex there are no issues:
local tbl = {}
print(tbl) -- table: <hash>
tbl.value = 0
print(tbl) -- table: <hash>
Also no issues if __newindex is a table:
local tbl = setmetatable({}, { __newindex = {} })
print(tbl) -- table: <hash>
tbl.value = 0
print(tbl) -- table: <hash>
Maybe it's related to #72?