Skip to content

Commit

Permalink
fix error after calling a nil value
Browse files Browse the repository at this point in the history
  • Loading branch information
xebecnan committed Nov 4, 2021
1 parent ec9711b commit f852154
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/symbols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@ local function find_id_symbol_aux(namespace, scope, name, narrow_func)
-- expand
local Types = require('types')
si = Types.get_node_type(si[1])
if si.tag == 'Id' and si[1] == 'Nil' then
si = { tag='Id', 'Any' }
if si then
if si.tag == 'Id' and si[1] == 'Nil' then
si = { tag='Id', 'Any' }
end
t[name] = si
end
t[name] = si
end
if si.tag == 'Id' and si[1] == 'Any' and narrow_func then
si = narrow_func(si)
t[name] = si
if si then
if si.tag == 'Id' and si[1] == 'Any' and narrow_func then
si = narrow_func(si)
t[name] = si
end
end
return si
end
Expand Down
5 changes: 4 additions & 1 deletion src/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ get_node_type_impl = function(ast)
end
elseif ast.tag == 'Call' then
local si = Symbols.find_var(ast[1])
if si.tag == 'TypeFunction' then
if not si then
-- called a nil value
return { tag='Id', 'Any' }
elseif si.tag == 'TypeFunction' then
-- require 函数
local require_path = ast.require_path
if require_path then
Expand Down

0 comments on commit f852154

Please sign in to comment.