diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-07-03 15:34:36 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-07-03 15:34:36 +0800 |
commit | 2dfed8a4aabd66c98777d37245ef5482b5ffdd48 (patch) | |
tree | ee64cc30276245ecca5542f044d9b9024b17c82b /script | |
parent | e5e7c27477b18857e8b07972a8f0b6589e2ffcb0 (diff) | |
download | lua-language-server-2dfed8a4aabd66c98777d37245ef5482b5ffdd48.zip |
fix
Diffstat (limited to 'script')
-rw-r--r-- | script/core/diagnostics/missing-return.lua | 2 | ||||
-rw-r--r-- | script/vm/function.lua | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/script/core/diagnostics/missing-return.lua b/script/core/diagnostics/missing-return.lua index 435e8a96..e3539ac0 100644 --- a/script/core/diagnostics/missing-return.lua +++ b/script/core/diagnostics/missing-return.lua @@ -63,7 +63,7 @@ return function (uri, callback) return end await.delay() - if vm.countReturnsOfFunction(source) == 0 then + if vm.countReturnsOfFunction(source, true) == 0 then return end if hasReturn(source) then diff --git a/script/vm/function.lua b/script/vm/function.lua index 5723fbc6..0e04408c 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -80,10 +80,11 @@ function vm.countParamsOfNode(node) end ---@param func parser.object +---@param onlyDoc? boolean ---@param mark? table ---@return integer min ---@return number max -function vm.countReturnsOfFunction(func, mark) +function vm.countReturnsOfFunction(func, onlyDoc, mark) if func.type == 'function' then ---@type integer? local min @@ -123,7 +124,7 @@ function vm.countReturnsOfFunction(func, mark) max = dmax end end - if not hasDocReturn and func.returns then + if not onlyDoc and not hasDocReturn and func.returns then for _, ret in ipairs(func.returns) do local rmin, rmax = vm.countList(ret, mark) if not min or rmin < min then @@ -153,7 +154,7 @@ function vm.countReturnsOfCall(func, args, mark) ---@type number? local max for _, f in ipairs(funcs) do - local rmin, rmax = vm.countReturnsOfFunction(f, mark) + local rmin, rmax = vm.countReturnsOfFunction(f, false, mark) if not min or rmin < min then min = rmin end |