You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
duplicate-set-field diagnostic when assigning a function to a table field #2551
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
I hit a related case with the official LÖVE addon installed through the VS Code addon manager (Lua extension 3.19.2). The addon library declares the callback as an API stub (function love.load(arg, unfilteredArg) end in library/love.lua), and a normal project implementation such as function love.load() ... end is then reported as Duplicate field "load" (duplicate-set-field). This is not a duplicate at runtime: the addon declaration is metadata/API information, while the project function implements the LÖVE callback. The same issue applies to callbacks such as love.draw/love.update. It appears the diagnostic is treating the metadata stub as a conflicting project definition. Workaround is disabling duplicate-set-field, but that suppresses useful warnings workspace-wide. Could meta/addon definitions be excluded when checking duplicate field assignments, or callback override/implementation be recognized?
Activity
pearagit commentedon Apr 5, 2024
chiming in that I also experience this
serialnumbers commentedon Oct 24, 2026
I hit a related case with the official LÖVE addon installed through the VS Code addon manager (Lua extension 3.19.2). The addon library declares the callback as an API stub (
function love.load(arg, unfilteredArg) endinlibrary/love.lua), and a normal project implementation such asfunction love.load() ... endis then reported asDuplicate field "load"(duplicate-set-field). This is not a duplicate at runtime: the addon declaration is metadata/API information, while the project function implements the LÖVE callback. The same issue applies to callbacks such aslove.draw/love.update. It appears the diagnostic is treating the metadata stub as a conflicting project definition. Workaround is disablingduplicate-set-field, but that suppresses useful warnings workspace-wide. Could meta/addon definitions be excluded when checking duplicate field assignments, or callback override/implementation be recognized?