diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-26 00:11:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-06-26 00:11:55 +0800 |
commit | ed64703ef9fec2b1c6736a0deb68bd567875a654 (patch) | |
tree | c46cc9347c00d8d55fe9a0b97a17ae629f474c8c /script/vm | |
parent | 2c6f0f9bf83f9a44c466aaf0d45ed9f8eab6c117 (diff) | |
download | lua-language-server-ed64703ef9fec2b1c6736a0deb68bd567875a654.zip |
#1207 supports `---@return boolean ...`
Diffstat (limited to 'script/vm')
-rw-r--r-- | script/vm/compiler.lua | 13 | ||||
-rw-r--r-- | script/vm/function.lua | 9 |
2 files changed, 17 insertions, 5 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index e62f7843..00c8170c 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -1519,9 +1519,16 @@ local compilerSwitch = util.switch() end end end - if lastReturn and not hasMarkDoc and lastReturn.types[1][1] == '...' then - hasMarkDoc = true - vm.setNode(source, vm.declareGlobal('type', 'unknown')) + if lastReturn + and not hasMarkDoc then + if lastReturn.types[1][1] == '...' then + hasMarkDoc = true + vm.setNode(source, vm.declareGlobal('type', 'unknown')) + end + if lastReturn.name and lastReturn.name[1] == '...' then + hasMarkDoc = true + vm.setNode(source, vm.compileNode(lastReturn)) + end end end local hasReturn diff --git a/script/vm/function.lua b/script/vm/function.lua index 9efcbd32..bdb70faf 100644 --- a/script/vm/function.lua +++ b/script/vm/function.lua @@ -113,8 +113,13 @@ function vm.countReturnsOfFunction(func, mark) end end end - if lastReturn and lastReturn.types[1][1] == '...' then - dmax = math.huge + if lastReturn then + if lastReturn.types[1][1] == '...' then + dmax = math.huge + end + if lastReturn.name and lastReturn.name[1] == '...' then + dmax = math.huge + end end if dmin and (not min or (dmin < min)) then min = dmin |