Re: Incorrect behaviour between tables in luajit and lua

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 20 Oct 2014 13:44:24 -0700

On Mon, Oct 20, 2014 at 1:41 PM, Eduardo Barthel <edub4rt@xxxxxxxxx> wrote:
> I see that unpack uses the length operator again, but shouldn't luajit
> behave like lua in such cases?

It DOES behave like Lua. You're invoking undefined behavior by using a
table with a nil in it. Undefined behavior has NO guarantees about its
behavior.

Even Lua will have different behaviors there depending on how you
construct that table. It's NOT guaranteed that #a will always return 3
for the table you've quoted.

/s/ Adam

Other related posts: