summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-02-22 12:06:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-02-22 12:06:27 +0800
commit5ab18375ca7f1b47fc589c30d419b23627e1a91f (patch)
tree2b5a0a5e07c44b6ec05b6d9a3650d66ae1fb1a22 /script/core
parentf0003c7e75767e42b34d24be6ce24bf90ead04cf (diff)
downloadlua-language-server-5ab18375ca7f1b47fc589c30d419b23627e1a91f.zip
fix runtime errors
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua6
1 files changed, 4 insertions, 2 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index 2e773fa5..17ccb817 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -1358,7 +1358,7 @@ end
local function checkTableLiteralField(ast, text, offset, call, funcs, index, results)
local source = findNearestSource(ast, offset)
if source.type ~= 'table'
- and source.parent.type ~= 'table' then
+ and (not source.parent or source.parent.type ~= 'table') then
return
end
if call.node and call.node.type == 'getmethod' then
@@ -1372,7 +1372,9 @@ local function checkTableLiteralField(ast, text, offset, call, funcs, index, res
end
for _, field in ipairs(vm.getDefFields(tbl, 0)) do
local name = guide.getKeyName(field)
- mark[name] = true
+ if name then
+ mark[name] = true
+ end
end
for _, func in ipairs(funcs) do
local param = getFuncParamByCallIndex(func, index)