lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 5 January 2012 15:21, Patrick Donnelly <batrick@batbytes.com> wrote:
On Wed, Jan 4, 2012 at 11:06 PM,  <alex.mania@iinet.net.au> wrote:
> Here's a demonstration: http://pastebin.com/zNtdfRrf
>
> I'm wondering:
>
> is the above undocumented but intended behaviour? (it'd be pretty nasty to
> document)

What you are doing is actually defined in the manual. All of the
expressions are evaluated before the assignment [1]. Any side effects
of the evaluation will take effect before the assignment is performed.
In this case, local a is overwritten with nil and you get an indexing
error.

[1] http://www.lua.org/manual/5.1/manual.html#2.4.3

--
- Patrick Donnelly

Then the bug is in line 2? (you should get an indexing nil error for the a[1] on the LHS)