-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Invalid fields injected warning #2341
Comments
I've been away for a while... but I think class references were becoming more strict. You may have to define the field in order for it to be mutable: ---@field a integer |
Is somewhere documented that fields, created via a table constructor are less mutable then fields created via the assignment operator? |
There is a very long thread where more strict classes are discussed. I personally got lost in all the suggestions, and I have been gone for a few weeks, so I'm not really sure what was implemented and what wasn't. |
Thanks for pointing it out. The injection warning likely is cause by some of the new changes. However I still think this warning is falsly generated: Both fields are defined even for the language server, the one defined in the table is just half existent. It won't allow any modifications, as it thinks the field inside the table doesn't really exist. |
There seems to be a few issues with the new warning, now a warning is falsly not generated: ---@class AnotherClass
local cl = {}
---@type AnotherClass
local o = {
x = true -- No Warning
}
o.x = false -- Correctly warned |
+1, running into this while modding Factorio, just in a slightly different configuration with ---@class Foo
local foo = {
bar = 1
}
---@param param Foo
local function fun(param)
param.bar = 2 -- inject-field warning, expected none
end |
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Windows
What is the issue affecting?
Type Checking, Diagnostics/Syntax Checking
Expected Behaviour
No warning.
Actual Behaviour
Reproduction steps
Additional Notes
When initializing a class with a table constructor, the used fields are no longer mutable, they seem to be semi existent. Existent enough for autocompletion and usage, but not for modifications.
Log File
No response
The text was updated successfully, but these errors were encountered: