-
-
Notifications
You must be signed in to change notification settings - Fork 351
bad Diagnostics. (inject-field) #2746
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
Comments
I just did some debugging and it seems that the for _, def in ipairs(vm.getDefs(src)) do
local dnode = def.node
if dnode
and not isExact
and vm.getDefinedClass(uri, dnode) then
return
end
if def.type == 'doc.type.field' then
return
end
if def.type == 'doc.field' then
return
end
-->>>>> missing the case below
if def.type == 'tablefield' then
return
end
--<<<<<
end However I am not 100% sure if the current behavior is by design. Maybe @NeOzay you can open a PR after testing the above code, and then ask maintainers about it? |
I'm going to try that |
after testing, your snippet does not seem to correct the problem. |
How did you test the change? It works in my computer 😕 I test it by changing the file inside the vscode extension folder, in my case it's the |
my bad, finally it works I'm going to make a PR |
the change does not pass the test suite. ---@class (exact) Class1
---@field x number
local m = {
x = 1, -- OK
y = 2, -- Warning
}
m.x = 1 -- OK
m.y = 2 -- Warning (no warning)
function m:init() -- OK
self.x = 1 -- OK
self.y = 2 -- Warning (no warning)
function self:xx() -- Warning
end
end |
how can we know if the class is in exact mode? if def.type == 'tablefield' and not exact then
return
end |
Sorry but I don't know much about the LuaLS codebase |
problem resolved, the PR passes the test suite. |
Why not just add |
I think you are talking about adding And I am sure that the current issue is a really a 🐛 , that's because if ---@class test
---@field position number
local test = {}
test.position = 0
test.started = false
---@param animation test
local function f1(animation)
animation.position = 1 -- ok
animation.started = false -- no warning here as expected
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?
Diagnostics/Syntax Checking
Expected Behaviour
the language server correctly deduces the type of the variable but indicates which is not declared.
only occurs when variables are declared at object creation.
Actual Behaviour
nothing
Reproduction steps
Additional Notes
No response
Log File
No response
The text was updated successfully, but these errors were encountered: