diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 20:11:14 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 20:11:14 +0800 |
commit | 097a36edf4cece5ce1b590adffc6de0d2929e995 (patch) | |
tree | 45a73f85fcc0c9c2cc393d1617eb95ed686cdd93 /script/vm/compiler.lua | |
parent | 1e6b168fa6d7a4922205cd19519e01f25898017e (diff) | |
download | lua-language-server-097a36edf4cece5ce1b590adffc6de0d2929e995.zip |
fix
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r-- | script/vm/compiler.lua | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 76e5c8d4..dad7d8f6 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -484,17 +484,28 @@ local function selectNode(source, list, index) result = m.compileNode(exp) end if source.type == 'function.return' then + -- remove any for returns + local rtnNode = union() local hasKnownType for n in nodeMgr.eachNode(result) do - if guide.isLiteral(n) - or (n.type == 'global' and n.cate == 'type') then + if guide.isLiteral(n) then hasKnownType = true - break + rtnNode:merge(n) + end + if n.type == 'global' and n.cate == 'type' then + if n.name ~= 'any' + and n.name ~= 'unknown' then + hasKnownType = true + rtnNode:merge(n) + end + else + rtnNode:merge(n) end end if not hasKnownType then - result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'unknown')) + rtnNode:merge(globalMgr.getGlobal('type', 'unknown')) end + return nodeMgr.setNode(source, rtnNode) end return nodeMgr.setNode(source, result) end |