summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2023-08-11 18:12:04 +0800
committer最萌小汐 <sumneko@hotmail.com>2023-08-11 18:12:04 +0800
commitf5fcab05b5a30373d1b35689d456090c8299c4c2 (patch)
tree831465f98d10c1d991be8c468157e4fb7d3d8168 /script
parent5e5a1b2ebb103625bbbb686ab31abc11a78e9d73 (diff)
downloadlua-language-server-f5fcab05b5a30373d1b35689d456090c8299c4c2.zip
support `---@type` and `--[[@as]]` for return
resolve #2144
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua10
1 files changed, 10 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 543ee0d4..7faa4f47 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1168,6 +1168,16 @@ local compilerSwitch = util.switch()
vm.compileCallArg(source, call)
end
+ if source.parent.type == 'return' then
+ local myIndex = util.arrayIndexOf(source.parent, source)
+ ---@cast myIndex -?
+ local parentNode = vm.selectNode(source.parent, myIndex)
+ if not parentNode:isEmpty() then
+ vm.setNode(source, parentNode)
+ return
+ end
+ end
+
if source.parent.type == 'setglobal'
or source.parent.type == 'local'
or source.parent.type == 'setlocal'