lua-users home
lua-l archive

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

On Thu, Jul 19, 2012 at 10:45 PM, Declan White <> wrote:
>> It looks like debug.setlocal does not correctly restore variables that
>> are localized inside subblocks in a function.

> You are storing the local variables by name, but their identifying key is numeric.
> To solve this, simply store by numeric local ID, rather than name.

It turned out to be not that simple as I want to be able to use the
same table to pass to setfenv(func, env) as an environment, so I need
those variables to be stored by name.

I ended up changing the way I process them and going from large IDs to
1 to make sure that I only update the innermost local variables and
ignore all others with the same name.