summaryrefslogtreecommitdiff
path: root/script/core/diagnostics
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-26 17:01:37 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-26 17:01:37 +0800
commit2896a055dc7e8b8e1cf711a98b12ac633328d974 (patch)
tree53a6660c8c6fdaaf8023782351f1565c3987d44e /script/core/diagnostics
parent3020a6e5eb4d36b4d694b8248e1d4bb639bfe435 (diff)
downloadlua-language-server-2896a055dc7e8b8e1cf711a98b12ac633328d974.zip
fix `close-non-object`
Diffstat (limited to 'script/core/diagnostics')
-rw-r--r--script/core/diagnostics/close-non-object.lua12
1 files changed, 5 insertions, 7 deletions
diff --git a/script/core/diagnostics/close-non-object.lua b/script/core/diagnostics/close-non-object.lua
index b9d3c485..fa587823 100644
--- a/script/core/diagnostics/close-non-object.lua
+++ b/script/core/diagnostics/close-non-object.lua
@@ -1,6 +1,7 @@
local files = require 'files'
local guide = require 'parser.guide'
local lang = require 'language'
+local vm = require 'vm'
return function (uri, callback)
local state = files.getState(uri)
@@ -23,18 +24,15 @@ return function (uri, callback)
}
return
end
- if source.value.type == 'nil'
- or source.value.type == 'number'
- or source.value.type == 'integer'
- or source.value.type == 'boolean'
- or source.value.type == 'table'
- or source.value.type == 'function' then
+ local infer = vm.getInfer(source.value)
+ if not infer:hasClass()
+ and not infer:hasType 'nil'
+ and infer:view('any', uri) ~= 'any' then
callback {
start = source.value.start,
finish = source.value.finish,
message = lang.script.DIAG_COSE_NON_OBJECT,
}
- return
end
end)
end