Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect hitting max local variable #64

Open
bubaflub opened this issue May 19, 2016 · 3 comments
Open

detect hitting max local variable #64

bubaflub opened this issue May 19, 2016 · 3 comments

Comments

@bubaflub
Copy link

Similar to #63

At work we've hit code that has more than the maximum number of local variables. Automated testing caught this but I think luacheck could have caught it for us as well. I believe the default limit is 200 local variables for a scope.

And since someone could technically compile lua with a different value, I think if we are going to check for this we should have a configuration option for what the maximum number of locals threshold is.

@bjorn
Copy link
Contributor

bjorn commented May 25, 2016

Good suggestion! We've run into this with our Lua code as well.

In our case, the shipped Lua code is obfuscated and the obfuscator adds some locals for its own purposes, so having a configuration option for setting the maximum to somewhat lower than the Lua default would indeed be useful.

@mpeterv
Copy link
Owner

mpeterv commented May 25, 2016

Ok, I'll need to check how Lua counts locals and upvalues and if there are differences between various versions of Lua and LuaJIT, then this should be simple to implement. Not sure about custom thresholds for now.

@bjorn you would probably want to run luacheck a second time, on the obfuscated code, checking only syntax errors to detect this instead of guessing how many locals can obfuscator add.

@bjorn
Copy link
Contributor

bjorn commented May 25, 2016

@bjorn you would probably want to run luacheck a second time, on the obfuscated code, checking only syntax errors to detect this instead of guessing how many locals can obfuscator add.

Yeah, that would be nice, but the power of luacheck for me is seeing the errors directly in Sublime Text while editing the code. The obfuscated code is only created on some build machine and it does already run some custom automatic checks there.

Not that this is an error one would run into much I think. In general, once you run into it once you'll probably avoid it easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants