In an assignment like 'a = &b', is looks suspicious if 'a' has a scope
larger than 'b'.
This commit is contained in:
Roberto I
2026-01-04 16:27:54 -03:00
parent c4e2c91973
commit 962f444a75

View File

@@ -1155,14 +1155,15 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key,
lua_assert(hres != HOK); lua_assert(hres != HOK);
if (hres == HNOTFOUND) { if (hres == HNOTFOUND) {
TValue aux; TValue aux;
const TValue *actk = key; /* actual key to insert */
if (l_unlikely(ttisnil(key))) if (l_unlikely(ttisnil(key)))
luaG_runerror(L, "table index is nil"); luaG_runerror(L, "table index is nil");
else if (ttisfloat(key)) { else if (ttisfloat(key)) {
lua_Number f = fltvalue(key); lua_Number f = fltvalue(key);
lua_Integer k; lua_Integer k;
if (luaV_flttointeger(f, &k, F2Ieq)) { if (luaV_flttointeger(f, &k, F2Ieq)) { /* is key equal to an integer? */
setivalue(&aux, k); /* key is equal to an integer */ setivalue(&aux, k);
key = &aux; /* insert it as an integer */ actk = &aux; /* use the integer as the key */
} }
else if (l_unlikely(luai_numisnan(f))) else if (l_unlikely(luai_numisnan(f)))
luaG_runerror(L, "table index is NaN"); luaG_runerror(L, "table index is NaN");
@@ -1175,7 +1176,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key,
L->top.p--; L->top.p--;
return; return;
} }
luaH_newkey(L, t, key, value); luaH_newkey(L, t, actk, value);
} }
else if (hres > 0) { /* regular Node? */ else if (hres > 0) { /* regular Node? */
setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value); setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value);