Leo Razoumov wrote:
> I am surprised to see that there are three different local 'x'
> variables. All of them belong to the same "block" which is foo()
> function body and, thus, should have the same scope. Why does not Lua
> collapses them into just one local x variable??
It's a feature of lua that the local keyword create a *new* local
variable, unconditionally. The end keyword closes a lexical scope, but
the beginning of the scope is not defined by the beginning of the block
but instead by the variable creation, which can happen after the
beginning of the block as in your examples (to be precise, the scope
starts just after variable initialisation, so a statement like "local
data = data.subdata" makes sense).