summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-23 23:46:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-23 23:46:53 +0800
commit3cadbfc7419542a8b56f0996bfbfbda146a30ea5 (patch)
tree216f4c4afff1240c84b395901bf7a7b0a9f78239 /script
parent0652fa586d62408e28d8f7d253aa96381d357bc8 (diff)
downloadlua-language-server-3cadbfc7419542a8b56f0996bfbfbda146a30ea5.zip
fix infer of `unknown and unknown`
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/need-check-nil.lua2
-rw-r--r--script/vm/compiler.lua3
-rw-r--r--script/vm/infer.lua20
3 files changed, 12 insertions, 13 deletions
diff --git a/script/core/diagnostics/need-check-nil.lua b/script/core/diagnostics/need-check-nil.lua
index 8654a7a6..98fdfd08 100644
--- a/script/core/diagnostics/need-check-nil.lua
+++ b/script/core/diagnostics/need-check-nil.lua
@@ -32,7 +32,7 @@ return function (uri, callback)
callback {
start = src.start,
finish = src.finish,
- message = lang.script('DIAG_MISS_NEED_CHECK_NIL'),
+ message = lang.script('DIAG_NEED_CHECK_NIL'),
}
end
end)
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 1f33a784..c69a7724 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1435,8 +1435,7 @@ local compilerSwitch = util.switch()
elseif r1 == false then
vm.setNode(source, node1)
else
- vm.getNode(source):merge(node2)
- vm.getNode(source):addOptional()
+ vm.setNode(source, node2)
end
end
if source.op.type == 'or' then
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index b5e717d5..410f9795 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -294,10 +294,6 @@ function mt:view(default, uri)
end
end
- if #array == 0 then
- return default or 'unknown'
- end
-
table.sort(array, function (a, b)
local sa = inferSorted[a] or 0
local sb = inferSorted[b] or 0
@@ -311,13 +307,17 @@ function mt:view(default, uri)
local limit = config.get(uri or self.uri, 'Lua.hover.enumsLimit')
local view
- if max > limit then
- view = string.format('%s...(+%d)'
- , table.concat(array, '|', 1, limit)
- , max - limit
- )
+ if #array == 0 then
+ view = default or 'unknown'
else
- view = table.concat(array, '|')
+ if max > limit then
+ view = string.format('%s...(+%d)'
+ , table.concat(array, '|', 1, limit)
+ , max - limit
+ )
+ else
+ view = table.concat(array, '|')
+ end
end
if self.node:isOptional() then