lua-users home
lua-l archive

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


I have the following problem with Lua 5.2 build on Windows, MSVC 2008:

Lua 5.2.0 (beta)  Copyright (C) 1994-2011, PUC-Rio
local t = {x=10,y=20}
local f1
do local _ENV=t
  function f1()
    return x+y
stdin:2: attempt to index local '_ENV' (a nil value)
stack traceback:
         stdin:2: in main chunk
         [C]: in ?

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?

I build the Lua interpreter from downloaded lua-5.2.0-beta source files via MSVC 2008; I just created an empty Win console project and I added all source files in it; luac.c must have been excluded from the build as it defines another main() (gives Lua compiler).

If you are familiar with MSVC, you can try the project from - just to check whether you will get the same behaviour.

BTW: I didn't find any Lua-5.2-for-Windows build/installer, so that's why I built Lua.exe myself.

BTW2: The whole discussion on "Struggling with _ENV in Lua 5.2" can be found at


NB: I sent this mail yesterday, but I probably was not subscribed to this mailing list yet; I apologize if I was and this mail is duplicated so.

Ing. Lukáš Procházka []
Pontex s. r. o.      [] []
Bezová 1658
147 14 Praha 4

Tel: +420 244 062 238
Fax: +420 244 461 038