test.lua
```lua
local function jcopy(o)
local function copy(v)
if type(v) == "table" then
local cv = {}
for key, value in pairs(v) do
if key == -1 then
error(tostring(key))
end
cv[key] = copy(value)
end
return cv
else
return v
end
end
return copy(o)
end
local function main()
local n = 0
for i = 1, 100, 1 do
local c = jcopy { cond = { { "you shouldn't see this via index -1" } } }
if c.cond[-1] then
if n == 0 then
-- print for the first time
print(c.cond[-1][1])
end
n = n + 1
end
end
if n > 0 then
print("-1 index happends:" .. n)
end
end
main()
```
then run `test.lua` 50 times
```sh
for ((i=1; i<=50; i++)); do resty test.lua; done
```
you will get output like:
```
root@DESKTOP-S3UK088:~/rsks# for ((i=1; i<=50; i++))
> do
> resty test.lua
> done
you shouldn't see this via index -1
-1 index happends:77
you shouldn't see this via index -1
-1 index happends:29
you shouldn't see this via index -1
-1 index happends:8
you shouldn't see this via index -1
-1 index happends:6
you shouldn't see this via index -1
-1 index happends:38
```
But you shouldn't see any output if the copy work as expected.
this is the minimal repo:
https://github.com/xiangnanscu/luajit-bug