aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ltable.c b/ltable.c
index 2f61be84..2f2b5c1f 100644
--- a/ltable.c
+++ b/ltable.c
@@ -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);