1
0
Fork 0
mirror of https://github.com/luau-lang/luau.git synced 2025-04-06 20:00:53 +01:00

Only assign metatable to clone if __metatable is undefined

This commit is contained in:
ccuser44 2025-01-02 15:25:09 +02:00 committed by GitHub
parent 489e79192a
commit bb14db9d91
Signed by: DevComp
GPG key ID: B5690EEEBB952194

View file

@ -797,7 +797,6 @@ Table* luaH_clone(lua_State* L, Table* tt)
{ {
Table* t = luaM_newgco(L, Table, sizeof(Table), L->activememcat); Table* t = luaM_newgco(L, Table, sizeof(Table), L->activememcat);
luaC_init(L, t, LUA_TTABLE); luaC_init(L, t, LUA_TTABLE);
t->metatable = tt->metatable;
t->tmcache = tt->tmcache; t->tmcache = tt->tmcache;
t->array = NULL; t->array = NULL;
t->sizearray = 0; t->sizearray = 0;
@ -808,6 +807,9 @@ Table* luaH_clone(lua_State* L, Table* tt)
t->node = cast_to(LuaNode*, dummynode); t->node = cast_to(LuaNode*, dummynode);
t->lastfree = 0; t->lastfree = 0;
if (!luaL_getmetafield(L, 1, "__metatable"))
t->metatable = tt->metatable;
if (tt->sizearray) if (tt->sizearray)
{ {
t->array = luaM_newarray(L, tt->sizearray, TValue, t->memcat); t->array = luaM_newarray(L, tt->sizearray, TValue, t->memcat);