diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-08-15 15:16:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-15 15:16:03 +0800 |
commit | 2c798703ca854d670fb28f51adc85c2b41f08f37 (patch) | |
tree | aa192cf6d6ed02d02dda8c8b7a4c240dded64efb /test/diagnostics | |
parent | abd5daae1885cdf7a9e21a1cbdfea945385124fc (diff) | |
parent | b71cb7aecd9337c9463a4dfbdb9d06cac7b825fd (diff) | |
download | lua-language-server-2c798703ca854d670fb28f51adc85c2b41f08f37.zip |
Merge branch 'master' into cast-table-to-class
Diffstat (limited to 'test/diagnostics')
-rw-r--r-- | test/diagnostics/missing-fields.lua | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/test/diagnostics/missing-fields.lua b/test/diagnostics/missing-fields.lua index ab87f81d..8c1ffbbb 100644 --- a/test/diagnostics/missing-fields.lua +++ b/test/diagnostics/missing-fields.lua @@ -231,3 +231,125 @@ local t = { y = 1, } ]] + +TEST [[ +---@diagnostic disable: unused-local + +---@class Foo +---@field a number +---@field b number +---@field c number + +---@class Foo + +---@class Bar +---@field ba number +---@field bb number +---@field bc number + +---@class Bar +---@field bd number + +---@type Foo|Bar +local x = { + ba = 1, + bb = 2, + bc = 3, + bd = 4, +} +]] + +TEST [[ +---@diagnostic disable: unused-local + +---@class Foo +---@field a number +---@field b number +---@field c number + +---@class Foo + +---@class Bar +---@field ba number +---@field bb number +---@field bc number + +---@class Bar +---@field bd number + +---@type Foo|Bar +local x = { + a = 1, + b = 2, + c = 3, +} +]] + +TEST [[ +---@diagnostic disable: unused-local + +---@class Foo +---@field a number +---@field b number +---@field c number + +---@class Foo + +---@class Bar +---@field ba number +---@field bb number +---@field bc number + +---@class Bar +---@field bd number + +---@type Foo|Bar +local x = <!{ + a = 1, + b = 2, +}!> +]] + +TEST [[ +---@diagnostic disable: unused-local + +---@class Foo +---@field a number +---@field b number +---@field c number + +---@class Foo + +---@class Bar +---@field ba number +---@field bb number +---@field bc number + +---@class Bar +---@field bd number + +---@type Foo|Bar +local x = <!{ + ba = 1, + bb = 2, + bd = 4, +}!> +]] + +TEST[[ +---@class A +---@field [1] string +---@field x number + +---@type A +local t = {x = 1, ""} +]] + +TEST[[ +---@class A +---@field [1] string +---@field x number + +---@type A +local t = <!{x = 1}!> +]]
\ No newline at end of file |