mpeterv / luacheck

A tool for linting and static analysis of Lua code.
MIT License
1.92k stars 322 forks source link

There seems has bug when check some specific lua source #139

Closed halx99 closed 7 years ago

halx99 commented 7 years ago

Critical error: Luacheck 0.21.1 bug (please report at github.com/mpeterv/luacheck/issues): attempt to index a nil value stack traceback: D:\develop\tools\luacheck\bin..\src\luacheck\utils.lua:186: in function <D:\develop\tools\luacheck\bin..\src\luacheck\utils.lua:182> [C]: in for iterator 'for iterator' ...elop\tools\luacheck\bin..\src\luacheck\reachability.lua:26: in local 'callback' ...evelop\tools\luacheck\bin..\src\luacheck\core_utils.lua:15: in function 'luacheck.core_utils.walk_line' (...tail calls...) ...elop\tools\luacheck\bin..\src\luacheck\reachability.lua:47: in function 'luacheck.reachability' ...elop\tools\luacheck\bin..\src\luacheck\reachability.lua:14: in local 'callback' ...evelop\tools\luacheck\bin..\src\luacheck\core_utils.lua:15: in function 'luacheck.core_utils.walk_line' (...tail calls...) ...elop\tools\luacheck\bin..\src\luacheck\reachability.lua:47: in function 'luacheck.reachability' D:\develop\tools\luacheck\bin..\src\luacheck\check.lua:238: in function <D:\develop\tools\luacheck\bin..\src\luacheck\check.lua:225> (...tail calls...) [C]: in function 'xpcall' D:\develop\tools\luacheck\bin..\src\luacheck\utils.lua:200: in function 'luacheck.utils.try' D:\develop\tools\luacheck\bin..\src\luacheck\check.lua:249: in function 'luacheck.check' (...tail calls...) D:\develop\tools\luacheck\bin..\src\luacheck\utils.lua:323: in function 'luacheck.utils.map' D:\develop\tools\luacheck\bin..\src\luacheck\main.lua:447: in upvalue 'get_new_reports' D:\develop\tools\luacheck\bin..\src\luacheck\main.lua:492: in local 'get_reports' D:\develop\tools\luacheck\bin..\src\luacheck\main.lua:590: in function <D:\develop\tools\luacheck\bin..\src\luacheck\main.lua:28> (...tail calls...) [C]: in function 'xpcall' D:\develop\tools\luacheck\bin..\src\luacheck\utils.lua:200: in function 'luacheck.utils.try' D:\develop\tools\luacheck\bin..\src\luacheck\main.lua:614: in main chunk [C]: in function 'require' D:\develop\tools\luacheck\bin\luacheck.lua:2: in main chunk [C]: in ?

mpeterv commented 7 years ago

Could you provide an example of Lua source that produces this error?

halx99 commented 7 years ago

I have test follow source will trigger this critical bug, save follow source to DummyClass.lua

local DummyClass = {}
function DummyClass:triggerCriticalBug()
    do return end
    local function dummyInnerFunction()
        self.dummy1 = self.dummy2 + self.dummy3;
    end
end
return DummyClass

DummyClass.zip

mpeterv commented 7 years ago

Should be fixed on master branch, at least the source you provided no longer causes a crash. I'll add some more tests and make a bugfix release in a day. Thanks for the report!

halx99 commented 7 years ago

You are welcome, this tool is excellent. It's very useful for Lua programming. Recently I will integrate it to my editor tool: https://github.com/halx99/x-studio365/issues/120 Thanks for you provide this tool.