From 0b8102e3774b74db5557a494567fb0a9c5da9013 Mon Sep 17 00:00:00 2001 From: NeOzay Date: Tue, 23 Jul 2024 17:14:37 +0200 Subject: improve missing-fields diagnostic logic --- test/diagnostics/missing-fields.lua | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) (limited to 'test/diagnostics') diff --git a/test/diagnostics/missing-fields.lua b/test/diagnostics/missing-fields.lua index ab87f81d..f1b1beae 100644 --- a/test/diagnostics/missing-fields.lua +++ b/test/diagnostics/missing-fields.lua @@ -231,3 +231,107 @@ 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 = +]] + +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 = +]] \ No newline at end of file -- cgit v1.2.3 From c08410458924a9f3c604e662cfce80f0f86d5b78 Mon Sep 17 00:00:00 2001 From: NeOzay Date: Wed, 24 Jul 2024 18:01:44 +0200 Subject: also detects missing index fields --- test/diagnostics/missing-fields.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/diagnostics') diff --git a/test/diagnostics/missing-fields.lua b/test/diagnostics/missing-fields.lua index f1b1beae..8c1ffbbb 100644 --- a/test/diagnostics/missing-fields.lua +++ b/test/diagnostics/missing-fields.lua @@ -334,4 +334,22 @@ local x = +]] + +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 = ]] \ No newline at end of file -- cgit v1.2.3