diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 17:25:15 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 17:25:15 +0800 |
commit | 4945fdb9092ba9dbecf1dc419f444763b6202a65 (patch) | |
tree | 08498d43063a4db7e56068143cfa15e0c8e539dc /script/vm/compiler.lua | |
parent | 6bb4453489dc86547d967f35308783f5823547e0 (diff) | |
download | lua-language-server-4945fdb9092ba9dbecf1dc419f444763b6202a65.zip |
reducing guess
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r-- | script/vm/compiler.lua | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index cbb03070..c92c224a 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -56,6 +56,9 @@ local searchFieldSwitch = util.switch() : call(function (node, key, pushResult) if node.cate == 'variable' then if key then + if type(key) ~= 'string' then + return + end local global = globalMgr.getGlobal('variable', node.name, key) if global then pushResult(global) @@ -88,14 +91,13 @@ local searchFieldSwitch = util.switch() end) : case 'doc.type.array' : call(function (node, key, pushResult) - if type(key) == 'number' - and key >= 1 - and math.tointeger(key) then - pushResult(node.node) - end - if key == nil then - pushResult(node.node) + if type(key) == 'number' then + if key < 1 + or not math.tointeger(key) then + return + end end + pushResult(node.node) end) : case 'doc.type.table' : call(function (node, key, pushResult) @@ -721,6 +723,12 @@ local compilerSwitch = util.switch() : call(function (source) compileByLocalID(source) local key = guide.getKeyName(source) + if key == nil and source.index then + key = m.compileNode(source.index) + end + if key == nil then + return + end m.compileByParentNode(source.node, key, function (src) if src.type == 'doc.type.field' or src.type == 'doc.field' then @@ -734,6 +742,12 @@ local compilerSwitch = util.switch() : call(function (source) compileByLocalID(source) local key = guide.getKeyName(source) + if key == nil and source.index then + key = m.compileNode(source.index) + end + if key == nil then + return + end m.compileByParentNode(source.node, key, function (src) nodeMgr.setNode(source, m.compileNode(src)) end) |