Closed bew closed 7 years ago
This is correct behaviour, inline options on the same line as some code only affect warnings for that line. If you move it one line above it will work as you want, ignoring all warnings related to do_something
in the rest of the code:
-- luacheck: ignore do_something
function do_something()
print('hello')
end
local function do_it()
do_something()
-- => bad luacheck error: accessing undefined variable 'do_something'
end
do_it()
See the part of https://luacheck.readthedocs.io/en/stable/inline.html after the table.
Not exactly what I want, I clarify:
The first ignore was intended to be for that line only. I don't want to ignore the last warning, because I think there shouldn't be a a warning on that line at all.
The last warning is accessing undefined variable
but the variable is defined, yes it's defined as a global, but it is defined!
And I don't think that just because the do_something
has a warning, the definition should be canceled..
Is it fully intentional?
Yes, a global must be explicitly defined using --globals
option or something equivalent. If you want to allow defining globals simply by assigning try --allow-defined
or --allow-defined-top
options, see https://luacheck.readthedocs.io/en/stable/warnings.html#implicitly-defined-globals.
I understand, thanks for your reply
With version :
Luacheck: 0.17.1
With the following snippet:
I get an incorrect error:
It does the same error if
do_something
is a variable set withoutlocal
If I change
do_something
to:There is no error