diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 13:39:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-03-15 13:39:25 +0800 |
commit | 035143c078f9e87b92a909b415d4d060db155604 (patch) | |
tree | bc53590d20bbfceb8ee3968793d3bc408ae4081f /server | |
parent | 37c2aaca32959f6c7862d7120379482f3ce811a3 (diff) | |
download | lua-language-server-035143c078f9e87b92a909b415d4d060db155604.zip |
库函数返回常量时使用新建值
Diffstat (limited to 'server')
-rw-r--r-- | server/src/vm/vm.lua | 3 | ||||
-rw-r--r-- | server/test/definition/bug.lua | 5 |
2 files changed, 8 insertions, 0 deletions
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 4a0250f1..555154b3 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -288,6 +288,9 @@ function mt:callLibrary(func, values, source, lib) if rtn.type == '...' then --func:getReturn(i):setType('any', 0.0) else + if rtn.type == 'boolean' or rtn.type == 'number' or rtn.type == 'integer' or rtn.type == 'string' then + func:setReturn(i, self:createValue(rtn.type, self:getDefaultSource())) + end func:getReturn(i):setType(rtn.type or 'any', 1.0) end end diff --git a/server/test/definition/bug.lua b/server/test/definition/bug.lua index b5e8dbe9..1d3ab02c 100644 --- a/server/test/definition/bug.lua +++ b/server/test/definition/bug.lua @@ -83,3 +83,8 @@ local a local <!b!> return f(), <?b?> ]] + +TEST [[ +local a = os.clock() +local <?<!b!>?> = os.clock() +]] |