summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/diagnostics/assign-type-mismatch.lua6
-rw-r--r--test/diagnostics/type-check.lua8
2 files changed, 11 insertions, 3 deletions
diff --git a/script/core/diagnostics/assign-type-mismatch.lua b/script/core/diagnostics/assign-type-mismatch.lua
index 3ec0a56c..abe78ccd 100644
--- a/script/core/diagnostics/assign-type-mismatch.lua
+++ b/script/core/diagnostics/assign-type-mismatch.lua
@@ -76,14 +76,14 @@ return function (uri, callback)
return
end
if source.type == 'setfield'
- or source.type == 'setindex'
- or source.type == 'tableexp' then
+ or source.type == 'setindex' then
return
end
end
local valueNode = vm.compileNode(value)
- if source.type == 'setindex' then
+ if source.type == 'setindex'
+ or source.type == 'tableexp' then
-- boolean[1] = nil
valueNode = valueNode:copy():removeOptional()
end
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index ff75f3cc..81cb1050 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -961,6 +961,14 @@ TEST [[
local t = { true, false, nil }
]]
+TEST [[
+---@type boolean|nil
+local x
+
+---@type boolean[]
+local t = { true, false, x }
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')