LuaLS / LuaLS/lua-language-server
duplicate-set-field diagnostic when assigning a function to a table field
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
### 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
No diagnostic warning on assignment because the variable has been 'cleared'.
### Actual Behaviour
The two info.func assignments that are "= function" get a Duplicate field 'func' (duplicate-set-field) diagnostic.
The info.func assignment "= l1" does not.
Scope depth does not seem to impact the diagnostic - within the same function.
Assignments to other fields that are string, integer, etc do not get the diagnostic.
FYI - the ".func" is expected in a library I cannot change.
### Reproduction steps
local function l1()
end
local function f1()
local info = {};
do
info = {};
info.notCheckable = true
info.func = function()
-- any code
end
end
info = {};
info.notCheckable = true
info.func = function()
-- any code
end
info = {};
info.notCheckable = true
info.func = l1
end
### Additional Notes
_No response_
### Log File
_No response_
Contributor guide
Research direction
Start with the reproduction steps and the duplicate-set-field diagnostic in the Diagnostics/Syntax Checking subsystem. Compare the three info.func assignments in the provided Lua snippet, then locate the diagnostic's existing tests or implementation. Done means the two inline function assignments no longer produce the reported warning while the l1 assignment and other duplicate-field checks remain covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100