summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-02-13 15:43:52 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-02-13 15:43:52 +0800
commit48a608d423901c75138d51c9bcffbb0c03f4f92f (patch)
tree14034ac9ed1b9c9e228b64760d5836c5b2c34e1d /test
parent457931e51b1fec849635fd43355de1215e058228 (diff)
downloadlua-language-server-48a608d423901c75138d51c9bcffbb0c03f4f92f.zip
fix #1902
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/type-check.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua
index 13df5a95..198ead64 100644
--- a/test/diagnostics/type-check.lua
+++ b/test/diagnostics/type-check.lua
@@ -1201,6 +1201,16 @@ local function some_fn(some_param) return end
some_fn { { "test" } } -- <- diagnostic: "Cannot assign `table` to `string`."
]]
+TEST [[
+---@param p integer|string
+local function get_val(p)
+ local is_number = type(p) == 'number'
+ return is_number and p or p
+end
+
+get_val('hi')
+]]
+
config.remove(nil, 'Lua.diagnostics.disable', 'unused-local')
config.remove(nil, 'Lua.diagnostics.disable', 'unused-function')
config.remove(nil, 'Lua.diagnostics.disable', 'undefined-global')