summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-15 11:28:00 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-15 11:28:00 +0800
commit6f0e8df7934b9c41aac83a6c0b4b0f50a9b50871 (patch)
tree6e342aec35fea50fbfc3ecccdb17e0b5f31c5965 /script/vm
parent51ee59203868cfe1177403a06d74ae7412c78f4d (diff)
downloadlua-language-server-6f0e8df7934b9c41aac83a6c0b4b0f50a9b50871.zip
fix #1698
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/compiler.lua3
-rw-r--r--script/vm/infer.lua9
2 files changed, 8 insertions, 4 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index a17cc5b2..2d7f2a69 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -991,7 +991,8 @@ local function compileLocal(source)
end
end
local hasMarkValue
- if not hasMarkDoc and source.value then
+ if (not hasMarkDoc and source.value)
+ or (source.value and source.value.type == 'table') then
hasMarkValue = true
if source.value.type == 'table' then
vm.setNode(source, source.value)
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index 00f1b014..b9dfb29a 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -534,11 +534,11 @@ end
---@return string|number|boolean|nil
function vm.viewKey(source, uri)
if source.type == 'doc.type' then
- if #source == 1 then
- return vm.viewKey(source[1], uri)
+ if #source.types == 1 then
+ return vm.viewKey(source.types[1], uri)
else
local key = vm.viewObject(source, uri)
- return '[' .. key .. ']', key
+ return '[' .. key .. ']'
end
end
if source.type == 'tableindex' then
@@ -564,6 +564,9 @@ function vm.viewKey(source, uri)
if source.type == 'doc.type.field' then
return vm.viewKey(source.name, uri)
end
+ if source.type == 'doc.type.name' then
+ return '[' .. source[1] .. ']'
+ end
local key = vm.getKeyName(source)
if key == nil then
return nil