summaryrefslogtreecommitdiff
path: root/test
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 /test
parenteca994d10e4f069a4cc9348d27a4f3723a19f551 (diff)
downloadlua-language-server-25cae7df6bff76e6a44adf85dfef06742ebf7193.zip
dose not infer as `nil` by `t.field = nil`
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/type-check.lua10
-rw-r--r--test/type_inference/init.lua10
2 files changed, 18 insertions, 2 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index cc60a969..082d0b41 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -570,9 +570,9 @@ end
]]
TEST [[
+---@class A
+---@field x number?
local t = {}
-t.x = 1
-t.x = nil
---@return number
function F()
@@ -688,5 +688,11 @@ local t
t = a.x
]]
+TEST [[
+local mt = {}
+mt.x = 1
+mt.x = nil
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 8e9e134f..bae14650 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3381,3 +3381,13 @@ TEST '{ [string]: number, [true]: string, [1]: boolean, tag: integer }' [[
---@type {[string]: number, [true]: string, [1]: boolean, tag: integer}
local <?t?>
]]
+
+TEST 'unknown' [[
+local mt = {}
+mt.<?x?> = nil
+]]
+
+TEST 'unknown' [[
+mt = {}
+mt.<?x?> = nil
+]]