lua-users home
lua-l archive

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


On Nov 11, 2011, at 8:13 AM, Procházka Lukáš Ing. - Pontex s. r. o. wrote:

> Lua 5.2.0 (beta)  Copyright (C) 1994-2011 Lua.org, PUC-Rio
>> local t = {x=10,y=20}
>> local f1
>> do local _ENV=t
>>>  function f1()
>>>    return x+y
>>>  end
>>> end
> stdin:2: attempt to index local '_ENV' (a nil value)
> stack traceback:
>         stdin:2: in main chunk
>         [C]: in ?
>> 
>> print(f1())
> stdin:1: attempt to call global 'f1' (a nil value)
> stack traceback:
>         stdin:1: in main chunk
>         [C]: in ?
> ----
> 
> Why? What am I doing wrong?

FWIW, works fine for me. Prints 30 as expected. So most likely something wrong with your build and/or how you execute your code.

http://alt.textdrive.com/assets/public/non/nq050816.gif