Re: Incorrect behaviour between tables in luajit and lua

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

I see, but now look this case, another different behaviour

bart@archrox:~ $ lua
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio
> a = {1,nil,3}
> pcall(print, unpack(a))
1 nil 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,3}
> pcall(print, unpack(a))
1


2014-10-20 18:28 GMT-02:00 Stefano <phd.st.p@xxxxxxxxx>:

> And I was going to reply as well....
>
> On 20 October 2014 22:26, Coda Highland <chighland@xxxxxxxxx> wrote:
> > 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
> >>
> >
>
>

Other related posts: