[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug with upvalue multi-assignment (corner case - Lua 5.x)
- From: Patrick Donnelly <batrick@...>
- Date: Wed, 4 Jan 2012 23:21:10 -0500
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