mirror of
https://github.com/lua/lua.git
synced 2026-01-27 01:44:31 +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:
parent
c4e2c91973
commit
962f444a75
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);
|
||||
if (hres == HNOTFOUND) {
|
||||
TValue aux;
|
||||
const TValue *actk = key; /* actual key to insert */
|
||||
if (l_unlikely(ttisnil(key)))
|
||||
luaG_runerror(L, "table index is nil");
|
||||
else if (ttisfloat(key)) {
|
||||
lua_Number f = fltvalue(key);
|
||||
lua_Integer k;
|
||||
if (luaV_flttointeger(f, &k, F2Ieq)) {
|
||||
setivalue(&aux, k); /* key is equal to an integer */
|
||||
key = &aux; /* insert it as an integer */
|
||||
if (luaV_flttointeger(f, &k, F2Ieq)) { /* is key equal to an integer? */
|
||||
setivalue(&aux, k);
|
||||
actk = &aux; /* use the integer as the key */
|
||||
}
|
||||
else if (l_unlikely(luai_numisnan(f)))
|
||||
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--;
|
||||
return;
|
||||
}
|
||||
luaH_newkey(L, t, key, value);
|
||||
luaH_newkey(L, t, actk, value);
|
||||
}
|
||||
else if (hres > 0) { /* regular Node? */
|
||||
setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user