diff --git a/VM/src/lgc.cpp b/VM/src/lgc.cpp index 690536d0..6e8dfd20 100644 --- a/VM/src/lgc.cpp +++ b/VM/src/lgc.cpp @@ -232,9 +232,9 @@ static LuaNode* relink(GCObject* o, LuaNode* n, LuaNode* list) { gkey(n)->extra[0] = static_cast(static_cast(intptr & 0xFFFFFFFF)); // Save the link to the next worklist entry in the key extra slot and value tt slot. // Note: The value tt is saved in the key tt which can be restored from the key GCObject. - if (sizeof(uintptr_t) > 4) { + if /* constexpr */ (sizeof(uintptr_t) > 4) { LUAU_ASSERT(sizeof(uintptr_t) <= 8); - gval(n)->tt = static_cast(static_cast(intptr >> 32)); + gval(n)->tt = static_cast(static_cast(static_cast(intptr) >> 32)); } return n; } @@ -273,8 +273,8 @@ static LuaNode* nextandrestore(LuaNode* n) { uintptr_t intptr = static_cast(gkey(n)->extra[0]); // Rebuild ptr to next element in the worklist which is stored in the key extra value // and the tt slot of the value. - if (sizeof(uintptr_t) > 4) { - intptr |= static_cast(static_cast(gval(n)->tt)) << 32; + if /* constexpr */ (sizeof(uintptr_t) > 4) { + intptr |= static_cast(static_cast(static_cast(gval(n)->tt)) << 32); } ttype(gval(n)) = ttype(gkey(n)); // Value tt is saved in the key tt. ttype(gkey(n)) = gcvalue(gkey(n))->gch.tt; // Key tt can be restored from the key gc value. diff --git a/tests/conformance/gc.lua b/tests/conformance/gc.lua index 5804ea7f..902296a5 100644 --- a/tests/conformance/gc.lua +++ b/tests/conformance/gc.lua @@ -132,14 +132,14 @@ print('weak tables') a = {}; setmetatable(a, {__mode = 'k'}); -- fill a with some `collectable' indices for i=1,lim do a[{}] = i end --- and some non-collectable ones for i=1,lim do local t={}; a[t]=t end +-- and some non-collectable ones for i=1,lim do a[i] = i end for i=1,lim do local s=string.rep('@', i); a[s] = s..'#' end collectgarbage() local i = 0 for k,v in pairs(a) do assert(k==v or k..'#'==v); i=i+1 end -assert(i == 3*lim) +assert(i == 2*lim) a = {}; setmetatable(a, {__mode = 'v'}); a[1] = string.rep('b', 21)