summaryrefslogtreecommitdiff
path: root/script/vm/infer.lua
diff options
context:
space:
mode:
authorlizho <lizho@msn.com>2024-01-30 09:36:41 +0800
committerGitHub <noreply@github.com>2024-01-30 09:36:41 +0800
commit7f95e6f71862967bcdc9ca1d78a1947dd177ca3e (patch)
treebf5a0a138c70b084d1dbacb6a8bcad3da19bbc64 /script/vm/infer.lua
parent9185dfad1286942b4914657e4c0e9ad28cb2aaa8 (diff)
downloadlua-language-server-7f95e6f71862967bcdc9ca1d78a1947dd177ca3e.zip
support tuple type
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r--script/vm/infer.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index f2673ed3..3f3d0e3a 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -157,22 +157,24 @@ local viewNodeSwitch;viewNodeSwitch = util.switch()
end
infer._hasClass = true
local buf = {}
- buf[#buf+1] = '{ '
+ buf[#buf+1] = source.isTuple and '[' or '{ '
for i, field in ipairs(source.fields) do
if i > 1 then
buf[#buf+1] = ', '
end
- local key = field.name
- if key.type == 'doc.type' then
- buf[#buf+1] = ('[%s]: '):format(vm.getInfer(key):view(uri))
- elseif type(key[1]) == 'string' then
- buf[#buf+1] = key[1] .. ': '
- else
- buf[#buf+1] = ('[%q]: '):format(key[1])
+ if not source.isTuple then
+ local key = field.name
+ if key.type == 'doc.type' then
+ buf[#buf+1] = ('[%s]: '):format(vm.getInfer(key):view(uri))
+ elseif type(key[1]) == 'string' then
+ buf[#buf+1] = key[1] .. ': '
+ else
+ buf[#buf+1] = ('[%q]: '):format(key[1])
+ end
end
buf[#buf+1] = vm.getInfer(field.extends):view(uri)
end
- buf[#buf+1] = ' }'
+ buf[#buf+1] = source.isTuple and ']' or ' }'
return table.concat(buf)
end)
: case 'doc.type.string'