summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/vm/type.lua3
-rw-r--r--test/diagnostics/type-check.lua7
3 files changed, 11 insertions, 0 deletions
diff --git a/changelog.md b/changelog.md
index 77e11e03..67fdb574 100644
--- a/changelog.md
+++ b/changelog.md
@@ -50,6 +50,7 @@
* `FIX` [#1284](https://github.com/sumneko/lua-language-server/issues/1284)
* `FIX` [#1292](https://github.com/sumneko/lua-language-server/issues/1292)
* `FIX` [#1294](https://github.com/sumneko/lua-language-server/issues/1294)
+* `FIX` [#1306](https://github.com/sumneko/lua-language-server/issues/1306)
* `FIX` [#1311](https://github.com/sumneko/lua-language-server/issues/1311)
* `FIX` [#1317](https://github.com/sumneko/lua-language-server/issues/1317)
* `FIX` [#1320](https://github.com/sumneko/lua-language-server/issues/1320)
diff --git a/script/vm/type.lua b/script/vm/type.lua
index 0432876c..fba39c2d 100644
--- a/script/vm/type.lua
+++ b/script/vm/type.lua
@@ -324,6 +324,9 @@ function vm.canCastType(uri, defNode, refNode)
if defInfer:view(uri) == 'unknown' then
return true
end
+ if refInfer:view(uri) == 'unknown' then
+ return true
+ end
if vm.isSubType(uri, refNode, 'nil') then
-- allow `local x = {};x = nil`,
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index b8951307..46cb2471 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -722,5 +722,12 @@ if t then
end
]]
+config.set(nil, 'Lua.type.weakUnionCheck', true)
+TEST [[
+---@type number
+local x = G
+]]
+config.set(nil, 'Lua.type.weakUnionCheck', false)
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')