From 40e0d3595961913aff0405369ddc9cbec2f743d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 26 Oct 2021 17:12:27 +0800 Subject: fix #753 --- changelog.md | 1 + script/core/hover/return.lua | 7 +++++++ script/core/infer.lua | 1 - test/hover/init.lua | 9 +++++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 41f7ea35..b9240098 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,7 @@ * `FIX` [#748](https://github.com/sumneko/lua-language-server/issues/748) * `FIX` [#749](https://github.com/sumneko/lua-language-server/issues/749) * `FIX` [#752](https://github.com/sumneko/lua-language-server/issues/752) +* `FIX` [#753](https://github.com/sumneko/lua-language-server/issues/753) * `FIX` [#756](https://github.com/sumneko/lua-language-server/issues/756) * `FIX` [#758](https://github.com/sumneko/lua-language-server/issues/758) diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua index 0f0d85e0..49f9536a 100644 --- a/script/core/hover/return.lua +++ b/script/core/hover/return.lua @@ -54,6 +54,13 @@ local function asFunction(source) line[#line+1] = ('% 3d. '):format(i) end for n = 1, #rtn do + if rtn[n].type == 'doc.type' then + for _, typeUnit in ipairs(rtn[n].types) do + if typeUnit[1] == 'nil' then + infers['nil'] = true + end + end + end local values = infer.searchInfers(rtn[n]) for tp in pairs(values) do infers[tp] = true diff --git a/script/core/infer.lua b/script/core/infer.lua index ab297209..6e667e65 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -216,7 +216,6 @@ local function searchLiteralOfValue(value, literals, mark) end end end - return end local function bindClassOrType(source) diff --git a/test/hover/init.lua b/test/hover/init.lua index 0a05e1cc..36fbd6d2 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1714,3 +1714,12 @@ local t: A { y: number, } ]] + +TEST [[ +---@return nil +local function () end +]] +[[ +function f() + -> nil +]] -- cgit v1.2.3