Skip to content

Missing fields on inherited class not resulting in diagnostics warnings #2598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
b0o opened this issue Apr 5, 2024 · 0 comments · Fixed by #2970
Closed

Missing fields on inherited class not resulting in diagnostics warnings #2598

b0o opened this issue Apr 5, 2024 · 0 comments · Fixed by #2970

Comments

@b0o
Copy link

b0o commented Apr 5, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant