summaryrefslogtreecommitdiff
path: root/server/src/vm/function.lua
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-29 19:45:38 +0800
committersumneko <sumneko@hotmail.com>2019-04-29 19:45:38 +0800
commitf2444b757331ddf8df16a39a86b0ce8608338d77 (patch)
tree65617574b497e87886470e6b504584fe099cbcd5 /server/src/vm/function.lua
parent1ec748aaa45599cb4487105842a1ad4cb5e7a2b4 (diff)
downloadlua-language-server-f2444b757331ddf8df16a39a86b0ce8608338d77.zip
emmy.generic
Diffstat (limited to 'server/src/vm/function.lua')
-rw-r--r--server/src/vm/function.lua24
1 files changed, 22 insertions, 2 deletions
diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua
index 4c2f0be5..5c9019aa 100644
--- a/server/src/vm/function.lua
+++ b/server/src/vm/function.lua
@@ -259,6 +259,13 @@ function mt:run(vm)
-- 向局部变量中填充参数
for i, loc in ipairs(self.args) do
loc:setValue(self.argValues[i])
+ local emmyParam = self:findEmmyParamByName(loc:getName())
+ if emmyParam then
+ local genericObj = emmyParam:bindGeneric()
+ if genericObj then
+ genericObj:setValue(loc:getValue())
+ end
+ end
end
if self._dots then
self._dots = createMulti()
@@ -271,7 +278,17 @@ function mt:run(vm)
if self._emmyReturns then
for i, rtn in ipairs(self._emmyReturns) do
local value = vm:createValue('nil', rtn:getSource())
- value:setEmmy(rtn:bindType())
+ local typeObj = rtn:bindType()
+ if typeObj then
+ value:setEmmy(typeObj)
+ end
+ local genericObj = rtn:bindGeneric()
+ if genericObj then
+ local destValue = genericObj:getValue()
+ if destValue then
+ value:mergeType(destValue)
+ end
+ end
self:setReturn(i, value)
end
end
@@ -307,7 +324,10 @@ function mt:createArg(vm, arg)
local emmyParam = self:findEmmyParamByName(arg[1])
local value = valueMgr.create('nil', arg)
if emmyParam then
- value:setEmmy(emmyParam:bindType())
+ local typeObj = emmyParam:bindType()
+ if typeObj then
+ value:setEmmy(typeObj)
+ end
end
local loc = localMgr.create(arg[1], arg, value)
self:saveUpvalue(arg[1], loc)