Comment 9 for bug 1378339

Revision history for this message
SirVer (sirver) wrote :

Should be fixed in r7222.

This was the problem: Some methods in format_help defined a variable "string" this way:

string = "blub" (instead of the correct 'local string = "blub"')

The problem here now is that all Lua methods share the same namespace - the global namespace - and that lua variables are global by default. So this little line did a ton of damage: it replaced the global string library [1] through an instance of a string. this did not do much trouble while running (since a string instance has all the methods of the string library), but on serilization, we did not know how to serialize the c methods of a string instance (we only know that we should not serialize the methods of the string library - but this one is gone).

I am quite concerned about this. It is a simple mistake to make and it could have been made in a scenario instead of a help text and would break saving of this scenario. Alas, I have no idea how to avoid it in the future. Quick googling found only this: http://stackoverflow.com/questions/7145984/making-global-environment-access-only-lua

Maybe having a Lua linter would help too - to make sure all variable declarations are always local.

[1] http://www.lua.org/pil/20.html