summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-06 16:01:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-06 16:01:05 +0800
commit25cae7df6bff76e6a44adf85dfef06742ebf7193 (patch)
tree8606dc8bf2d7c539206f66ee888f24cdac3c7b3c /script
parenteca994d10e4f069a4cc9348d27a4f3723a19f551 (diff)
downloadlua-language-server-25cae7df6bff76e6a44adf85dfef06742ebf7193.zip
dose not infer as `nil` by `t.field = nil`
Diffstat (limited to 'script')
-rw-r--r--script/core/diagnostics/assign-type-mismatch.lua16
-rw-r--r--script/vm/compiler.lua4
2 files changed, 12 insertions, 8 deletions
diff --git a/script/core/diagnostics/assign-type-mismatch.lua b/script/core/diagnostics/assign-type-mismatch.lua
index 6809760c..0cccc7ee 100644
--- a/script/core/diagnostics/assign-type-mismatch.lua
+++ b/script/core/diagnostics/assign-type-mismatch.lua
@@ -64,16 +64,20 @@ return function (uri, callback)
return
end
end
- --[[
- ---@class A
- local mt
- ---@type X
- mt._x = nil -- don't warn this
- ]]
if value.type == 'nil' then
+ --[[
+ ---@class A
+ local mt
+ ---@type X
+ mt._x = nil -- don't warn this
+ ]]
if hasMarkType(source) then
return
end
+ if source.type == 'setfield'
+ or source.type == 'setindex' then
+ return
+ end
end
local valueNode = vm.compileNode(value)
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 67ca3b41..12cf102b 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1387,7 +1387,7 @@ local compilerSwitch = util.switch()
if src.value then
if bindDocs(src) then
vm.setNode(source, vm.compileNode(src))
- else
+ elseif src.value.type ~= 'nil' then
vm.setNode(source, vm.compileNode(src.value))
local node = vm.getNode(src)
if node then
@@ -1949,7 +1949,7 @@ local function compileByGlobal(source)
vm.setNode(set, globalNode, true)
end
for _, set in ipairs(global:getSets(uri)) do
- if set.value then
+ if set.value and set.value.type ~= 'nil' then
if not hasMarkDoc or guide.isLiteral(set.value) then
globalNode:merge(vm.compileNode(set.value))
end