diff options
-rw-r--r-- | server/src/vm/function.lua | 14 | ||||
-rw-r--r-- | 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 <?f?>() + ---@type integer + local a + return a +end +]] +[[ +function f() + -> any +]] + +TEST [[ +---@return any +function f() + ---@type integer + local a + return a +end + +local <?x?> = f() +]] +[[ +local x: any +]] |