summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-06-28 21:06:53 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-06-28 21:06:53 +0800
commit08b9dd387a9b912c68749018b7dfe3c1df7094d5 (patch)
tree46c81598c214b10643f3d8083bb7b64b9e2ba21c /test
parent9ad317f2a1eb8dc5715103c8c62e0fcff88a482b (diff)
downloadlua-language-server-08b9dd387a9b912c68749018b7dfe3c1df7094d5.zip
cleanup
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/type-check.lua11
-rw-r--r--test/type_inference/init.lua9
2 files changed, 20 insertions, 0 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index e79c767d..862bc0bf 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -588,5 +588,16 @@ end
f(nil)
]]
+TEST [[
+---@return number
+function F()
+ local n = 0
+ if true then
+ n = 1
+ end
+ return n
+end
+]]
+
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 3cf381d1..61677cea 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3200,3 +3200,12 @@ local n
if not n or not <?n?>[1] then
end
]]
+
+TEST 'number' [[
+---@type number|false
+local n
+
+---@cast n -false
+
+print(<?n?>)
+]]