lua-users home
lua-l archive

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

On 2 July 2014 00:04, David Demelier <> wrote:
Le 01/07/2014 15:08, Andrew Starks a écrit :

Told from the perspective of _javascript_, but most of it applies to Lua, as well.


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 [1] plugins.



There are tools like FindGlobals[1] 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).