mirror of
https://github.com/lua/lua.git
synced 2026-06-07 23:53:48 +00:00
Details
In an assignment like 'a = &b', is looks suspicious if 'a' has a scope larger than 'b'.
This commit is contained in:
9
ltable.c
9
ltable.c
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user