diff options
-rw-r--r-- | script/core/diagnostics/unused-local.lua | 18 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 20 |
2 files changed, 14 insertions, 24 deletions
diff --git a/script/core/diagnostics/unused-local.lua b/script/core/diagnostics/unused-local.lua index d12ceb2b..a637f427 100644 --- a/script/core/diagnostics/unused-local.lua +++ b/script/core/diagnostics/unused-local.lua @@ -63,18 +63,16 @@ local function isDocClass(source) return false end -local function isDocParam(source) - if not source.bindDocs then +---@param source parser.object +local function isDeclareFunctionParam(source) + if source.parent.type ~= 'funcargs' then return false end - for _, doc in ipairs(source.bindDocs) do - if doc.type == 'doc.param' then - if doc.param[1] == source[1] then - return true - end - end + local func = source.parent.parent + if #func > 0 then + return false end - return false + return true end return function (uri, callback) @@ -94,7 +92,7 @@ return function (uri, callback) if isDocClass(source) then return end - if vm.isMetaFile(uri) and isDocParam(source) then + if isDeclareFunctionParam(source) then return end local data = hasGet(source) diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 1f8a782d..759039a6 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -439,12 +439,14 @@ local <!x!> = {} TEST [[ local function f(<!self!>) + return 'something' end f() ]] TEST [[ local function f(<!...!>) + return 'something' end f() ]] @@ -1047,20 +1049,6 @@ end ]] TEST [[ ----@param a number -return function (<!a!>) -end -]] - -TEST [[ ----@meta - ----@param a number -return function (a) -end -]] - -TEST [[ local m = {} function <!m:fff!>() @@ -1703,3 +1691,7 @@ function t:init() end <!t.init()!> ]] + +TEST [[ +return function f(x, y, z) end +]] |