File tree Expand file tree Collapse file tree 3 files changed +115
-4
lines changed Expand file tree Collapse file tree 3 files changed +115
-4
lines changed Original file line number Diff line number Diff line change 22
33## Unreleased
44<!-- Add all new changes here. They will be moved under a version at release -->
5- ` 2024-11-26 `
5+ * ` FIX ` missing-fields diagnostic now warns about missing inherited fields
66* ` CHG ` Update Love2d version
77
88## 3.13.2
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ return function (uri, callback)
4141 for className , samedefs in pairs (sortedDefs ) do
4242 local missedKeys = {}
4343 for _ , def in ipairs (samedefs ) do
44- if not def .fields or # def .fields == 0 then
44+ local fields = vm .getFields (def )
45+ if # fields == 0 then
4546 goto continue
4647 end
4748
@@ -55,7 +56,7 @@ return function (uri, callback)
5556 end
5657 end
5758
58- for _ , field in ipairs (def . fields ) do
59+ for _ , field in ipairs (fields ) do
5960 if not field .optional
6061 and not vm .compileNode (field ):isNullable () then
6162 local key = vm .getKeyName (field )
Original file line number Diff line number Diff line change @@ -352,4 +352,114 @@ TEST[[
352352
353353---@type A
354354local t = <!{x = 1}!>
355- ]]
355+ ]]
356+
357+ -- Inheritance
358+
359+ TEST [[
360+ ---@class A
361+ ---@field x number
362+
363+ ---@class B: A
364+
365+ ---@type B
366+ local t = <!{}!>
367+ ]]
368+
369+ TEST [[
370+ ---@class A
371+ ---@field x number
372+ ---@field y number
373+
374+ ---@class B: A
375+
376+ ---@type B
377+ local t = <!{y = 1}!>
378+ ]]
379+
380+ TEST [[
381+ ---@class A
382+ ---@field x number
383+
384+ ---@class B: A
385+ ---@field y number
386+
387+ ---@type B
388+ local t = <!{y = 1}!>
389+ ]]
390+
391+ -- Inheritance + optional
392+
393+ TEST [[
394+ ---@class A
395+ ---@field x? number
396+
397+ ---@class B: A
398+
399+ ---@type B
400+ local t = {}
401+ ]]
402+
403+ TEST [[
404+ ---@class A
405+ ---@field x? number
406+ ---@field y number
407+
408+ ---@class B: A
409+
410+ ---@type B
411+ local t = {y = 1}
412+ ]]
413+
414+ TEST [[
415+ ---@class A
416+ ---@field x? number
417+
418+ ---@class B: A
419+ ---@field y number
420+
421+ ---@type B
422+ local t = {y = 1}
423+ ]]
424+
425+ -- Inheritance + function call
426+
427+ TEST [[
428+ ---@class A
429+ ---@field x number
430+
431+ ---@class B: A
432+
433+ ---@param b B
434+ local function f(b) end
435+
436+ f <!{}!>
437+ ]]
438+
439+ TEST [[
440+ ---@class A
441+ ---@field x number
442+ ---@field y number
443+
444+ ---@class B: A
445+
446+ ---@param b B
447+ local function f(b) end
448+
449+ f <!{y = 1}!>
450+ ]]
451+
452+ TEST [[
453+ ---@class A
454+ ---@field x number
455+
456+ ---@class B: A
457+ ---@field y number
458+
459+ ---@param b B
460+ local function f(b) end
461+
462+ f <!{y = 1}!>
463+ ]]
464+
465+ --
You can’t perform that action at this time.
0 commit comments