diff options
-rw-r--r-- | script/vm/tracer.lua | 29 | ||||
-rw-r--r-- | test/type_inference/init.lua | 13 |
2 files changed, 28 insertions, 14 deletions
diff --git a/script/vm/tracer.lua b/script/vm/tracer.lua index f8d99800..b97df135 100644 --- a/script/vm/tracer.lua +++ b/script/vm/tracer.lua @@ -326,10 +326,10 @@ function mt:lookIntoChild(action, topNode, outNode) self:lookIntoBlock(action, actionStart, topNode:copy()) local lastAssign = self:getLastAssign(action.start, action.finish) if lastAssign then - local node = self:getNode(lastAssign) - if node then - topNode = node:copy() - end + self:getNode(lastAssign) + end + if self.nodes[action] then + topNode = self.nodes[action]:copy() end end elseif action.type == 'while' then @@ -344,10 +344,10 @@ function mt:lookIntoChild(action, topNode, outNode) self:lookIntoBlock(action, action.keyword[4], blockNode:copy()) local lastAssign = self:getLastAssign(action.start, action.finish) if lastAssign then - local node = self:getNode(lastAssign) - if node then - topNode = mainNode:merge(node) - end + self:getNode(lastAssign) + end + if self.nodes[action] then + topNode = mainNode:merge(self.nodes[action]) end end if action.filter then @@ -388,11 +388,11 @@ function mt:lookIntoChild(action, topNode, outNode) else local lastAssign = self:getLastAssign(subBlock.start, subBlock.finish) if lastAssign then - local node = self:getNode(lastAssign) - if node then - blockNodes[#blockNodes+1] = node - mergedNode = true - end + self:getNode(lastAssign) + end + if self.nodes[subBlock] then + blockNodes[#blockNodes+1] = self.nodes[subBlock] + mergedNode = true end end end @@ -461,10 +461,11 @@ function mt:lookIntoBlock(block, start, node) node = self:lookIntoChild(action, node) end if action.finish > start and self.assignMap[action] then - break + return end ::CONTINUE:: end + self.nodes[block] = node end ---@param source parser.object diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua index 85cbf683..e89133c2 100644 --- a/test/type_inference/init.lua +++ b/test/type_inference/init.lua @@ -4080,3 +4080,16 @@ local function x() print(<?x?>) end ]] + +TEST 'number' [[ +---@type number? +local x + +do + if not x then + return + end +end + +print(<?x?>) +]] |