summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-27 17:46:51 +0800
committerGitHub <noreply@github.com>2021-09-27 17:46:51 +0800
commit98167f4e9eb2794dbaceb50dc79ac75867413ea1 (patch)
treeb1c698bafd113c0407aa3144fad48256e8394a85 /test
parentabb018af20a69d866d857738b64bc6975c10de22 (diff)
parent626032b400af1cf79823a9a004ad2d0937599153 (diff)
downloadlua-language-server-98167f4e9eb2794dbaceb50dc79ac75867413ea1.zip
Merge pull request #685 from ArtistArthur/ar/typecheck
add typecheck
Diffstat (limited to 'test')
-rw-r--r--test/diagnostics/init.lua78
1 files changed, 77 insertions, 1 deletions
diff --git a/test/diagnostics/init.lua b/test/diagnostics/init.lua
index 5f69bdc9..1b26c00b 100644
--- a/test/diagnostics/init.lua
+++ b/test/diagnostics/init.lua
@@ -460,7 +460,7 @@ f(1, 2, 3)
]]
TEST [[
-<!unpack!>(1)
+<!unpack!>(<!1!>)
]]
TEST [[
@@ -1133,3 +1133,79 @@ return {
[<!2!>] = 4,
}
]]
+
+TEST [[
+---@param table table
+---@param metatable table
+---@return table
+function Setmetatable(table, metatable) end
+
+Setmetatable(<!1!>, {})
+]]
+
+TEST [[
+---@param table table
+---@param metatable table
+---@return table
+function Setmetatable(table, metatable) end
+
+Setmetatable(<!'name'!>, {})
+
+]]
+
+TEST [[
+---@param table table
+---@param metatable table
+---@return table
+function Setmetatable(table, metatable) end
+
+---@type table
+local name
+---@type function
+local mt
+---err
+Setmetatable(name, <!mt!>)
+]]
+
+TEST [[
+---@param p1 string
+---@param p2 number
+---@return table
+local function func1(p1, p2) end
+
+---@type string
+local s
+---@type table
+local t
+---err
+func1(s, <!t!>)
+]]
+
+TEST [[
+---@class bird
+---@field wing string
+
+---@class eagle
+---@field family bird
+
+---@class chicken
+---@field family bird
+
+---@param bd eagle
+local function fly(bd) end
+
+---@type chicken
+local h
+fly(<!h!>)
+]]
+
+TEST [[
+---@overload fun(x: number, y: number)
+---@param x boolean
+---@param y boolean
+local function f(x, y) end
+
+f(true, true) -- OK
+f(0, 0) -- OK
+
+]] \ No newline at end of file