lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Missing fields on inherited class not resulting in diagnostics warnings

Open b0o opened this issue 1 year ago • 0 comments

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Linux

What is the issue affecting?

Annotations, Type Checking, Diagnostics/Syntax Checking

Expected Behaviour

Should be a type error to not include all required fields from both parent and child class.

Actual Behaviour

Only fields from the child class are required.

With an empty table, we get a warning about missing the fields from the child class:

2024-04-05_06-15-08_region

When we fill in those fields, we get no warnings, even though the fields from the parent class are still missing:

2024-04-05_06-15-18_region

If we explicitly assign nil, we do get warnings:

2024-04-05_06-30-41_region

Reproduction steps

Check the diagnostics for the following snippets:

---@class Parent
---@field a string
---@field b string

---@class Child : Parent
---@field c string
---@field d string

---@type Child
local my_child = {} -- We get a warning here saying `c` and `d` are missing
---@class Parent
---@field a string
---@field b string

---@class Child : Parent
---@field c string
---@field d string

---@type Child
local my_child = {
  c = 'c',
  d = 'd',
} -- but no diagnostics here, even though `a` and `b` are missing

Additional Notes

No response

Log File

No response

b0o avatar Apr 05 '24 13:04 b0o