Incorrect behaviour between tables in luajit and lua

  • From: Eduardo Barthel <edub4rt@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 20 Oct 2014 18:17:55 -0200

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

Other related posts: