diff options
author | sumneko <sumneko@hotmail.com> | 2022-03-06 23:35:11 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2022-03-06 23:35:11 +0800 |
commit | 4946063175c1a0cda7a11877b8c2b21b0c447c5f (patch) | |
tree | 164045515811f64bab018fc498bc5bc84a45de70 /script | |
parent | 7d9b22159083dd7b55def45e87bb883060253d30 (diff) | |
download | lua-language-server-4946063175c1a0cda7a11877b8c2b21b0c447c5f.zip |
update
Diffstat (limited to 'script')
-rw-r--r-- | script/vm/compiler.lua | 6 | ||||
-rw-r--r-- | script/vm/generic.lua | 30 |
2 files changed, 34 insertions, 2 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 624b4964..b5d31436 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -227,8 +227,10 @@ local function getReturn(func, index, source, args) local returnNode = getReturnOfFunction(cnode, index) if returnNode and returnNode.type == 'generic' then local argNodes = {} - for i, arg in ipairs(args) do - argNodes[i] = m.compileNode(arg) + if args then + for i, arg in ipairs(args) do + argNodes[i] = m.compileNode(arg) + end end returnNode = returnNode:resolve(argNodes) end diff --git a/script/vm/generic.lua b/script/vm/generic.lua index e7423d3c..7080623c 100644 --- a/script/vm/generic.lua +++ b/script/vm/generic.lua @@ -15,6 +15,36 @@ local function cloneObject(node, resolved) local key = node[1] return resolved[key] end + if node.type == 'doc.type' then + local newType = { + type = node.type, + start = node.start, + finish = node.finish, + parent = node.parent, + types = {}, + } + for i, typeUnit in ipairs(node.types) do + newType.types[i] = cloneObject(typeUnit, resolved) + end + return newType + end + if node.type == 'doc.type.function' then + local newDocFunc = { + type = node.type, + start = node.start, + finish = node.finish, + parent = node.parent, + args = {}, + returns = {}, + } + for i, arg in ipairs(node.args) do + newDocFunc.args[i] = cloneObject(arg, resolved) + end + for i, ret in ipairs(node.returns) do + newDocFunc.returns[i] = cloneObject(ret, resolved) + end + return newDocFunc + end return nil end |