diff --git a/VM/src/ltable.cpp b/VM/src/ltable.cpp index dafb2b3f..635212f6 100644 --- a/VM/src/ltable.cpp +++ b/VM/src/ltable.cpp @@ -797,7 +797,6 @@ Table* luaH_clone(lua_State* L, Table* tt) { Table* t = luaM_newgco(L, Table, sizeof(Table), L->activememcat); luaC_init(L, t, LUA_TTABLE); - t->metatable = tt->metatable; t->tmcache = tt->tmcache; t->array = NULL; t->sizearray = 0; @@ -808,6 +807,9 @@ Table* luaH_clone(lua_State* L, Table* tt) t->node = cast_to(LuaNode*, dummynode); t->lastfree = 0; + if (!luaL_getmetafield(L, 1, "__metatable")) + t->metatable = tt->metatable; + if (tt->sizearray) { t->array = luaM_newarray(L, tt->sizearray, TValue, t->memcat);