This isn't a bug at all. You're invoking undefined behavior -- # is only well-defined for sequences, and a sequence is defined as not containing embedded nils. /s/ Adam On Mon, Oct 20, 2014 at 1:17 PM, Eduardo Barthel <edub4rt@xxxxxxxxx> wrote: > While using LuaJIT in my apps I found this bug while declaring a new table > with "nil" value in the middle, read the following examples, while in Lua > the output is 3 in LuajIT is 1. > > Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio >> a = {1,nil,2} >> print(#a) > 3 > > bart@archrox:~ $ lua5.1 > Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio >> a = {1,nil,2} >> print(#a) > 3 > > bart@archrox:~ $ luajit > LuaJIT 2.0.3 -- Copyright (C) 2005-2014 Mike Pall. http://luajit.org/ > JIT: ON CMOV SSE2 SSE3 SSE4.1 fold cse dce fwd dse narrow loop abc sink fuse >> a = {1,nil,2} >> print(#a) > 1 >