diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 14:53:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 14:53:11 +0800 |
commit | 78b3a317d66d3066ccda8570737e2ecbe76c6568 (patch) | |
tree | f1fc4471cf76f7b6d707095a5570be058fd6413c | |
parent | 67a341f3fa26e5a3140cde3420ef2269a84d478f (diff) | |
download | lua-language-server-78b3a317d66d3066ccda8570737e2ecbe76c6568.zip |
cleanup
-rw-r--r-- | script/vm/compiler.lua | 29 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 10 |
2 files changed, 17 insertions, 22 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index a87f2eba..eeea3c87 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -338,12 +338,11 @@ local function getReturn(func, index, args) end local node = m.compileNode(func) ---@type vm.node.union - local result, hasCalled + local result if node then for cnode in nodeMgr.eachNode(node) do if cnode.type == 'function' or cnode.type == 'doc.type.function' then - hasCalled = true local returnNode = m.getReturnOfFunction(cnode, index) if returnNode and returnNode.type == 'generic' then returnNode = returnNode:resolve(args) @@ -355,9 +354,6 @@ local function getReturn(func, index, args) end end end - if not hasCalled then - result = globalMgr.getGlobal('type', 'unknown') - end return result end @@ -471,19 +467,18 @@ local function selectNode(source, list, index) else result = m.compileNode(exp) end - if not result then - return nodeMgr.setNode(source, result) - end - local hasKnownType - for n in nodeMgr.eachNode(result) do - if guide.isLiteral(n) - or (n.type == 'global' and n.cate == 'type') then - hasKnownType = true - break + if source.type == 'function.return' then + local hasKnownType + for n in nodeMgr.eachNode(result) do + if guide.isLiteral(n) + or (n.type == 'global' and n.cate == 'type') then + hasKnownType = true + break + end + end + if not hasKnownType then + result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'unknown')) end - end - if not hasKnownType then - result = nodeMgr.mergeNode(result, globalMgr.getGlobal('type', 'unknown')) end return nodeMgr.setNode(source, result) end diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index f79f1872..722bdea7 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -1378,8 +1378,8 @@ TEST [[ ---@class A 1 ]] -TEST [[ -local value -value = '1' -value = value:gsub() -]] +--TEST [[ +--local value +--value = '1' +--value = value:gsub() +--]] |