diff options
| author | Roberto I <roberto@inf.puc-rio.br> | 2026-01-04 16:27:54 -0300 |
|---|---|---|
| committer | Roberto I <roberto@inf.puc-rio.br> | 2026-01-04 16:27:54 -0300 |
| commit | 962f444a755882ecfc24ca7e96ffe193d64ed12d (patch) | |
| tree | 9163e692e8f127e8774a1b58ac25d2c5c70c747f /ltable.c | |
| parent | c4e2c91973fed04e7da940c00c92f10f9eb0f9ec (diff) | |
| download | lua-962f444a755882ecfc24ca7e96ffe193d64ed12d.tar.gz lua-962f444a755882ecfc24ca7e96ffe193d64ed12d.tar.bz2 lua-962f444a755882ecfc24ca7e96ffe193d64ed12d.zip | |
Details
In an assignment like 'a = &b', is looks suspicious if 'a' has a scope
larger than 'b'.
Diffstat (limited to 'ltable.c')
| -rw-r--r-- | ltable.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1155,14 +1155,15 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key, | |||
| 1155 | lua_assert(hres != HOK); | 1155 | lua_assert(hres != HOK); |
| 1156 | if (hres == HNOTFOUND) { | 1156 | if (hres == HNOTFOUND) { |
| 1157 | TValue aux; | 1157 | TValue aux; |
| 1158 | const TValue *actk = key; /* actual key to insert */ | ||
| 1158 | if (l_unlikely(ttisnil(key))) | 1159 | if (l_unlikely(ttisnil(key))) |
| 1159 | luaG_runerror(L, "table index is nil"); | 1160 | luaG_runerror(L, "table index is nil"); |
| 1160 | else if (ttisfloat(key)) { | 1161 | else if (ttisfloat(key)) { |
| 1161 | lua_Number f = fltvalue(key); | 1162 | lua_Number f = fltvalue(key); |
| 1162 | lua_Integer k; | 1163 | lua_Integer k; |
| 1163 | if (luaV_flttointeger(f, &k, F2Ieq)) { | 1164 | if (luaV_flttointeger(f, &k, F2Ieq)) { /* is key equal to an integer? */ |
| 1164 | setivalue(&aux, k); /* key is equal to an integer */ | 1165 | setivalue(&aux, k); |
| 1165 | key = &aux; /* insert it as an integer */ | 1166 | actk = &aux; /* use the integer as the key */ |
| 1166 | } | 1167 | } |
| 1167 | else if (l_unlikely(luai_numisnan(f))) | 1168 | else if (l_unlikely(luai_numisnan(f))) |
| 1168 | luaG_runerror(L, "table index is NaN"); | 1169 | luaG_runerror(L, "table index is NaN"); |
| @@ -1175,7 +1176,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key, | |||
| 1175 | L->top.p--; | 1176 | L->top.p--; |
| 1176 | return; | 1177 | return; |
| 1177 | } | 1178 | } |
| 1178 | luaH_newkey(L, t, key, value); | 1179 | luaH_newkey(L, t, actk, value); |
| 1179 | } | 1180 | } |
| 1180 | else if (hres > 0) { /* regular Node? */ | 1181 | else if (hres > 0) { /* regular Node? */ |
| 1181 | setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value); | 1182 | setobj2t(L, gval(gnode(t, hres - HFIRSTNODE)), value); |
