-
Notifications
You must be signed in to change notification settings - Fork 93
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
Usage of '...' outside a vararg function is not throwing an error #74
Comments
This is actually a parse-time error; were it a run-time error, I would probably reject this report as invalid. The only documented way to obtain command-line arguments in Lua is via the assert(load([[
local a, b, c = ...
print(a) -- prints 1
print(b) -- prints 2
print(c) -- prints 3
]]))(1, 2, 3)
So this seems to be an obscure feature, but with potentially valid use. In a later version I may introduce a warning lint against it (that is, when I introduce warning lints in the first place). |
May I suggest to make a separate project/repository for linter, and use |
Well, it's a bit of a gray area what should be considered a mere lint and what should be a compile-time error anyway. On one hand you have programming languages with sophisticated type systems where even the slightest possibility of a logic error causes the program to be rejected at compile time. On the other, you have bash and TeX, which are so dynamic that they don't even have a separate ‘compile time’ in the first place. (And for this reason they’re a nightmare to program anything nontrivial in, even more than JS.) I can very well imagine an implementation of Lua which doesn't diagnose any coding errors beyond respecting the basic recursive grammar (like gotos pointing to nowhere, or in fact the issue you reported here) until the very last moment at run time. As far as I am concerned, it would be perfectly compliant to the language specification, if somewhat silly. But if you’re wondering, the design I have in mind right now would be to remake luaparse into something vaguely event-driven, where lint plugins could seamlessly listen to specific events and track their own metadata independently of each other. That should make it easy to spin off the various lints into independent projects if so desired. |
Fixed in f3354f3. |
For example:
x=function()print(...)end x()
function y()print(...)end y()
_G['z']=function()print(...)end z()
The above are parsed "correctly" by luaparse, however they are illegal at runtime.
The following is valid:
print(...) -- in the root scope, probably to obtain arguments on command-line
I think this behaviour is documented.
Would be hard to fix ? (not sure)
The text was updated successfully, but these errors were encountered: