Skip to content

Commit f074686

Browse files
committed
fix missing-fields
1 parent 7c63635 commit f074686

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

script/core/diagnostics/missing-fields.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,16 @@ return function (uri, callback)
1717

1818
local defs = vm.getDefs(src)
1919
local requiresKeys = {}
20+
local isClass = false
2021
for _, def in ipairs(defs) do
2122
if def.type == 'doc.class' then
2223
if not def.fields then
2324
goto continue
2425
end
2526
if def.bindSource then
2627
if guide.isInRange(def.bindSource, src.start) then
27-
goto continue
28+
isClass = true
29+
break
2830
end
2931
end
3032
for _, field in ipairs(def.fields) do
@@ -41,7 +43,7 @@ return function (uri, callback)
4143
::continue::
4244
end
4345

44-
if #requiresKeys == 0 then
46+
if #requiresKeys == 0 or isClass then
4547
return
4648
end
4749

test/diagnostics/common.lua

+17
Original file line numberDiff line numberDiff line change
@@ -2414,3 +2414,20 @@ f {
24142414
z = 3,
24152415
}
24162416
]]
2417+
2418+
TEST [[
2419+
---@diagnostic disable: unused-local
2420+
---@class A
2421+
---@field x number
2422+
local t = {}
2423+
]]
2424+
2425+
TEST [[
2426+
---@diagnostic disable: unused-local
2427+
2428+
---@class A
2429+
---@field x number
2430+
2431+
---@class A
2432+
local t = {}
2433+
]]

0 commit comments

Comments
 (0)