diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-10 12:09:35 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-06-10 12:09:35 -0300 |
| commit | 94b503d95ef00f1e38b58b024ef45bf8973a8746 (patch) | |
| tree | c713558a386934bc1d251f064c8d9fae1fb725c0 /ltests.c | |
| parent | bdc85357aa41a9610498232c2cffe7aa191e5cf6 (diff) | |
| download | lua-94b503d95ef00f1e38b58b024ef45bf8973a8746.tar.gz lua-94b503d95ef00f1e38b58b024ef45bf8973a8746.tar.bz2 lua-94b503d95ef00f1e38b58b024ef45bf8973a8746.zip | |
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.
Diffstat (limited to 'ltests.c')
| -rw-r--r-- | ltests.c | 4 |
1 files changed, 2 insertions, 2 deletions
| @@ -365,7 +365,7 @@ static void checktable (global_State *g, Table *h) { | |||
| 365 | checkobjrefN(g, hgc, h->metatable); | 365 | checkobjrefN(g, hgc, h->metatable); |
| 366 | for (i = 0; i < asize; i++) { | 366 | for (i = 0; i < asize; i++) { |
| 367 | TValue aux; | 367 | TValue aux; |
| 368 | arr2obj(h, i + 1, &aux); | 368 | arr2obj(h, i, &aux); |
| 369 | checkvalref(g, hgc, &aux); | 369 | checkvalref(g, hgc, &aux); |
| 370 | } | 370 | } |
| 371 | for (n = gnode(h, 0); n < limit; n++) { | 371 | for (n = gnode(h, 0); n < limit; n++) { |
| @@ -1010,7 +1010,7 @@ static int table_query (lua_State *L) { | |||
| 1010 | } | 1010 | } |
| 1011 | else if (cast_uint(i) < asize) { | 1011 | else if (cast_uint(i) < asize) { |
| 1012 | lua_pushinteger(L, i); | 1012 | lua_pushinteger(L, i); |
| 1013 | arr2obj(t, i + 1, s2v(L->top.p)); | 1013 | arr2obj(t, i, s2v(L->top.p)); |
| 1014 | api_incr_top(L); | 1014 | api_incr_top(L); |
| 1015 | lua_pushnil(L); | 1015 | lua_pushnil(L); |
| 1016 | } | 1016 | } |
