diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2023-07-20 18:08:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2023-07-20 18:08:35 +0800 |
commit | 297ac3aabb38c22648f501038e1e66b6c8f9f936 (patch) | |
tree | e9c40686abd45a1aeba3e6d863d015c2117c8429 /test/diagnostics | |
parent | e7bc0940a32a99adc2bbce746d118e59faddcc07 (diff) | |
download | lua-language-server-297ac3aabb38c22648f501038e1e66b6c8f9f936.zip |
new diagnostic: `missing-fields`
Diffstat (limited to 'test/diagnostics')
-rw-r--r-- | test/diagnostics/common.lua | 150 | ||||
-rw-r--r-- | test/diagnostics/type-check.lua | 1 |
2 files changed, 149 insertions, 2 deletions
diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index a1dbe819..d061b4e4 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -156,13 +156,13 @@ print(A) -- no warning TEST [[ ---@type iolib -_ENV = {} +_ENV = io <!print!>(stderr) -- `print` is warning but `stderr` is not ]] TEST [[ ---@type iolib -local _ENV = {} +local _ENV = io <!print!>(stderr) -- `print` is warning but `stderr` is not ]] @@ -2206,6 +2206,7 @@ end TEST [[ ---@diagnostic disable: unused-local +---@diagnostic disable: missing-fields ---@class A ---@field private x number local mt = {} @@ -2220,6 +2221,7 @@ end TEST [[ ---@diagnostic disable: unused-local +---@diagnostic disable: missing-fields ---@class A ---@field private x number local mt = {} @@ -2268,3 +2270,147 @@ local function foo(_ENV) Joe = "human" end ]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@type A +local t = <!{}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@type A +local t = <!{ + x = 1, +}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@type A +local t = <!{ + x = 1, + y = 2, +}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@type A +local t = { + x = 1, + y = 2, + z = 3, +} +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@type A +local t = { + x = 1, + z = 3, +} +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@param a A +local function f(a) end + +f <!{}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@param a A +local function f(a) end + +f <!{ + x = 1, +}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@param a A +local function f(a) end + +f <!{ + x = 1, + y = 2, +}!> +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@param a A +local function f(a) end + +f { + x = 1, + y = 2, + z = 3, +} +]] + +TEST [[ +---@diagnostic disable: unused-local +---@class A +---@field x number +---@field y? number +---@field z number + +---@param a A +local function f(a) end + +f { + x = 1, + z = 3, +} +]] diff --git a/test/diagnostics/type-check.lua b/test/diagnostics/type-check.lua index dd9d1198..adfef561 100644 --- a/test/diagnostics/type-check.lua +++ b/test/diagnostics/type-check.lua @@ -174,6 +174,7 @@ m.ints = {} ]] TEST [[ +---@diagnostic disable: missing-fields ---@class A ---@field x A |