summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-17 17:44:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-17 17:44:51 +0800
commit1abbbdc89bb5511aead3ac8155ae68265b90a6e9 (patch)
tree37458759e015edcf0e9650df0fcb1155978c44ed /script/vm
parent09f1cf4e0380437087536ec0d79eddae44a0e569 (diff)
downloadlua-language-server-1abbbdc89bb5511aead3ac8155ae68265b90a6e9.zip
some fix
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua8
-rw-r--r--script/vm/node.lua11
2 files changed, 18 insertions, 1 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 103239c1..dd41d7b6 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -641,7 +641,12 @@ local function compileByLocalID(source)
if src.value then
if not hasMarkDoc or guide.isLiteral(src.value) then
if src.value.type ~= 'nil' then
- vm.setNode(source, vm.compileNode(src.value))
+ local valueNode = vm.compileNode(src.value)
+ if valueNode:hasType 'unknown' then
+ vm.setNode(source, valueNode:copy():remove 'unknown')
+ else
+ vm.setNode(source, valueNode)
+ end
end
end
end
@@ -1296,6 +1301,7 @@ local compilerSwitch = util.switch()
return
end
compileByLocalID(source)
+ ---@type string|vm.node
local key = guide.getKeyName(source)
if key == nil and source.index then
key = vm.compileNode(source.index)
diff --git a/script/vm/node.lua b/script/vm/node.lua
index 39ed219e..1ff229fa 100644
--- a/script/vm/node.lua
+++ b/script/vm/node.lua
@@ -269,6 +269,17 @@ function mt:removeNode(node)
end
end
+---@param name string
+---@return boolean
+function mt:hasType(name)
+ for _, c in ipairs(self) do
+ if c.type == 'global' and c.cate == 'type' and c.name == name then
+ return true
+ end
+ end
+ return false
+end
+
---@return fun():vm.object
function mt:eachObject()
local i = 0