@@ -651,10 +651,9 @@ static void reinserthash (lua_State *L, Table *ot, Table *t) {
651651
652652
653653/*
654- ** Exchange the hash part of 't1' and 't2'. (In 'flags', only the
655- ** dummy bit must be exchanged: The 'isrealasize' is not related
656- ** to the hash part, and the metamethod bits do not change during
657- ** a resize, so the "real" table can keep their values.)
654+ ** Exchange the hash part of 't1' and 't2'. (In 'flags', only the dummy
655+ ** bit must be exchanged: The metamethod bits do not change during a
656+ ** resize, so the "real" table can keep their values.)
658657*/
659658static void exchangehashpart (Table * t1 , Table * t2 ) {
660659 lu_byte lsizenode = t1 -> lsizenode ;
@@ -1156,14 +1155,15 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key,
11561155 lua_assert (hres != HOK );
11571156 if (hres == HNOTFOUND ) {
11581157 TValue aux ;
1158+ const TValue * actk = key ; /* actual key to insert */
11591159 if (l_unlikely (ttisnil (key )))
11601160 luaG_runerror (L , "table index is nil" );
11611161 else if (ttisfloat (key )) {
11621162 lua_Number f = fltvalue (key );
11631163 lua_Integer k ;
1164- if (luaV_flttointeger (f , & k , F2Ieq )) {
1165- setivalue (& aux , k ); /* key is equal to an integer */
1166- key = & aux ; /* insert it as an integer */
1164+ if (luaV_flttointeger (f , & k , F2Ieq )) { /* is key equal to an integer? */
1165+ setivalue (& aux , k );
1166+ actk = & aux ; /* use the integer as the key */
11671167 }
11681168 else if (l_unlikely (luai_numisnan (f )))
11691169 luaG_runerror (L , "table index is NaN" );
@@ -1176,7 +1176,7 @@ void luaH_finishset (lua_State *L, Table *t, const TValue *key,
11761176 L -> top .p -- ;
11771177 return ;
11781178 }
1179- luaH_newkey (L , t , key , value );
1179+ luaH_newkey (L , t , actk , value );
11801180 }
11811181 else if (hres > 0 ) { /* regular Node? */
11821182 setobj2t (L , gval (gnode (t , hres - HFIRSTNODE )), value );
0 commit comments