File tree 3 files changed +115
-4
lines changed
3 files changed +115
-4
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Unreleased
4
4
<!-- 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
6
6
* ` CHG ` Update Love2d version
7
7
8
8
## 3.13.2
Original file line number Diff line number Diff line change @@ -41,7 +41,8 @@ return function (uri, callback)
41
41
for className , samedefs in pairs (sortedDefs ) do
42
42
local missedKeys = {}
43
43
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
45
46
goto continue
46
47
end
47
48
@@ -55,7 +56,7 @@ return function (uri, callback)
55
56
end
56
57
end
57
58
58
- for _ , field in ipairs (def . fields ) do
59
+ for _ , field in ipairs (fields ) do
59
60
if not field .optional
60
61
and not vm .compileNode (field ):isNullable () then
61
62
local key = vm .getKeyName (field )
Original file line number Diff line number Diff line change @@ -352,4 +352,114 @@ TEST[[
352
352
353
353
---@type A
354
354
local 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