From 23c895e096b8bf9c0873ce3efaca862db246e236 Mon Sep 17 00:00:00 2001 From: sumneko Date: Mon, 27 May 2019 11:32:49 +0800 Subject: =?UTF-8?q?fixed=20#40=20=E5=BC=BA=E5=88=B6=E4=BD=BF=E7=94=A8=20@r?= =?UTF-8?q?eturn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/function.lua | 14 ++++++++++++-- server/test/hover/init.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 1106a0c9..a6f2b0cf 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -145,7 +145,7 @@ function mt:loadLabel(name) return nil end -function mt:setReturn(index, value) +function mt:rawSetReturn(index, value) if self._removed then return end @@ -161,10 +161,20 @@ function mt:setReturn(index, value) end end +function mt:setReturn(index, value) + if self._emmyReturns then + return + end + return self:rawSetReturn(index, value) +end + function mt:mergeReturn(index, value) if self._removed then return end + if self._emmyReturns then + return + end self:set('hasReturn', true) if not self.returns then self.returns = createMulti() @@ -324,7 +334,7 @@ function mt:run(vm) value:mergeType(destValue) end end - self:setReturn(i, value) + self:rawSetReturn(i, value) end end end diff --git a/server/test/hover/init.lua b/server/test/hover/init.lua index e568335d..cff6af65 100644 --- a/server/test/hover/init.lua +++ b/server/test/hover/init.lua @@ -769,3 +769,30 @@ local names: { [*integer]: string, } ]] + +TEST [[ +---@return any +function () + ---@type integer + local a + return a +end +]] +[[ +function f() + -> any +]] + +TEST [[ +---@return any +function f() + ---@type integer + local a + return a +end + +local = f() +]] +[[ +local x: any +]] -- cgit v1.2.3