Le 01/07/2014 16:33, Choonster TheMage a écrit :
It does not seems to work for 5.2 unfortunately:On 2 July 2014 00:04, David Demelier <firstname.lastname@example.org> wrote:
Le 01/07/2014 15:08, Andrew Starks a écrit :For me, one of the only thing I do agree is that the lack of static analysis can lead to bugs. In Lua if I type:
The code will obviously load as there are no syntax error, but will fail at the execution since unexistant is not a defined variable. In C++, you will actually have an error at the compilation. For that issue, you can only check at runtime and personally, it's the only problem I have when I develop irccd  plugins.
There are tools like FindGlobals that analyse the output of luac to detect global variable access (intentional or otherwise). FindGlobals also allows you to whitelist certain global names so they don't show up in the output.
FindGlobals is only for Lua 5.1, but it could probably be easily adapted for 5.2. I'm pretty sure there are existing alternatives for 5.2, but I can't think of their names at the moment.
Although FindGlobals is distributed from a World of Warcraft AddOn site, it's meant to run in a standard Lua 5.1 environment (and in fact can't run inside WoW's embedded Lua due to sandbox restrictions).
~/test $ cat test.lua
~/test $ luac52 -l -p test.lua|lua52 findglobals/globals.lua test.lua