Skip to content

Instantly share code, notes, and snippets.

@mpeterv
Created June 8, 2015 18:40
Show Gist options
  • Select an option

  • Save mpeterv/2362928a80d2b92cb17c to your computer and use it in GitHub Desktop.

Select an option

Save mpeterv/2362928a80d2b92cb17c to your computer and use it in GitHub Desktop.
luajit 2.1.0 testcase
-- The following code should print "nil" several times,
-- but one of the nils gets replaced with a table somehow.
local function key(expr)
if type(expr) == 'table' then
-- Removing the zero removes spurious table
local res = {0}
for i=1, #expr do
res[i] = key(expr[i])
-- Uncommenting the following line removes spurious table
-- io.stdout:write()
end
-- This unexpectedly prints "table: 0xaddress" once
print(res[2])
end
return
end
-- Turning jit off removes spurious table
-- jit.off()
key { 0,
{ 0,
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0,
{ 0, 0, 0 },
0 },
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0, 0 },
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0, 0, 0 },
0 },
0 },
{ 0 }
},
0 },
{ 0 }
},
0 },
{ 0 },
{ 0,
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0,
{ 0, 0, 0 },
0 },
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0, 0,
{ 0, 0, 0 }
},
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0, 0, 0 },
0 },
0 },
{ 0 }
},
0 },
{ 0 }
},
0 },
{ 0,
{ 0, 0, 0 },
{ 0,
{ 0, 0 },
{ 0,
{ 0,
{ 0, 0,
{ 0, 0, 0 }
}
}
}
},
0 }
}
},
{ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment