diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-08-13 04:26:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-08-13 04:26:14 +0800 |
commit | 6c82c0f9f83d364fd8965e1c13a3b57aa67f5520 (patch) | |
tree | ee9fe1872fd0c09cd2f9e60e6d23f6a5a2a194ef /script/vm | |
parent | 680ffb800e7fa8f16241407cfb83de0ff38aa0ad (diff) | |
download | lua-language-server-6c82c0f9f83d364fd8965e1c13a3b57aa67f5520.zip |
fix #1463
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/type.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/script/vm/type.lua b/script/vm/type.lua index d112be2c..be3eff98 100644 --- a/script/vm/type.lua +++ b/script/vm/type.lua @@ -252,6 +252,17 @@ function vm.isSubType(uri, child, parent, mark) return false end +---@param node string|vm.node|vm.object +function vm.isUnknown(node) + if type(node) == 'string' then + return node == 'unknown' + end + if node.type == 'vm.node' then + return not node:hasKnownType() + end + return false +end + ---@param uri uri ---@param tnode vm.node ---@param knode vm.node|string @@ -280,6 +291,9 @@ function vm.getTableValue(uri, tnode, knode, inversion) result:merge(vm.compileNode(tn.node)) end if tn.type == 'table' then + if vm.isUnknown(knode) then + goto CONTINUE + end for _, field in ipairs(tn) do if field.type == 'tableindex' and field.value then @@ -315,6 +329,7 @@ function vm.getTableValue(uri, tnode, knode, inversion) end end end + ::CONTINUE:: end if result:isEmpty() then return nil @@ -350,6 +365,9 @@ function vm.getTableKey(uri, tnode, vnode, reverse) result:merge(vm.declareGlobal('type', 'integer')) end if tn.type == 'table' then + if vm.isUnknown(tnode) then + goto CONTINUE + end for _, field in ipairs(tn) do if field.type == 'tableindex' then if field.index then @@ -364,6 +382,7 @@ function vm.getTableKey(uri, tnode, vnode, reverse) end end end + ::CONTINUE:: end if result:isEmpty() then return nil |