summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changelog.md1
-rw-r--r--script/core/hover/return.lua7
-rw-r--r--script/core/infer.lua1
-rw-r--r--test/hover/init.lua9
4 files changed, 17 insertions, 1 deletions
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<string, number> {
y: number,
}
]]
+
+TEST [[
+---@return nil
+local function <?f?>() end
+]]
+[[
+function f()
+ -> nil
+]]