-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
missing-fields diagnostic doesn't check for fields of inherited classes #2966
Comments
There are already many duplicated issues concerning this 😅 |
Oops I forgot to search issues again after realizing what was the actual bug |
Do I close this? |
This code fixes it locally, but I don't know what really changes from doing that. Should I open a PR? - for _, field in ipairs(def.fields) do
+ for _, field in ipairs(vm.getFields(def)) do |
I am not familiar with that part of the codebase as well, but just judging from the code inside lua-language-server/script/core/diagnostics/missing-fields.lua Lines 41 to 44 in 1bc0131
---@class A
---@field a integer
---@class B: A
-- no extra defined fields for class `B`
---@type B
local b1 = { a = 1 } -- No warning shown
---@type B
local b2 = { b = 2 } -- No warning shown
local fields = vm.getFields(def)
if #fields == 0 then
goto continue
end then use In addition, I don't know if using |
Thanks for the extensive response! Good catch for that issue |
How are you using the lua-language-server?
Other
Which OS are you using?
Windows
What is the issue affecting?
Type Checking, Diagnostics/Syntax Checking
Expected Behaviour
Initializing a class instance warns of missing fields from the inherited classes.
Actual Behaviour
Initializing a class instance only checks that the fields defined in the class are present, fields inherited from other classes aren't checked, so if one of them is missing, there's no warning.
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: