Encoding of table indices (hres) must use C indices
As the encoding of array indices is (~index), 0 is encoded as -1 and INT_MAX is encoded as INT_MIN.
This commit is contained in:
4
ltests.c
4
ltests.c
@@ -365,7 +365,7 @@ static void checktable (global_State *g, Table *h) {
|
||||
checkobjrefN(g, hgc, h->metatable);
|
||||
for (i = 0; i < asize; i++) {
|
||||
TValue aux;
|
||||
arr2obj(h, i + 1, &aux);
|
||||
arr2obj(h, i, &aux);
|
||||
checkvalref(g, hgc, &aux);
|
||||
}
|
||||
for (n = gnode(h, 0); n < limit; n++) {
|
||||
@@ -1010,7 +1010,7 @@ static int table_query (lua_State *L) {
|
||||
}
|
||||
else if (cast_uint(i) < asize) {
|
||||
lua_pushinteger(L, i);
|
||||
arr2obj(t, i + 1, s2v(L->top.p));
|
||||
arr2obj(t, i, s2v(L->top.p));
|
||||
api_incr_top(L);
|
||||
lua_pushnil(L);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user