Skip to content

Commit ef7d403

Browse files
committed
fix
1 parent 7155b72 commit ef7d403

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

script/vm/tracer.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ function mt:lookIntoChild(action, topNode, outNode)
326326
self:lookIntoBlock(action, actionStart, topNode:copy())
327327
local lastAssign = self:getLastAssign(action.start, action.finish)
328328
if lastAssign then
329-
local node = self:getNode(lastAssign)
330-
if node then
331-
topNode = node:copy()
332-
end
329+
self:getNode(lastAssign)
330+
end
331+
if self.nodes[action] then
332+
topNode = self.nodes[action]:copy()
333333
end
334334
end
335335
elseif action.type == 'while' then
@@ -344,10 +344,10 @@ function mt:lookIntoChild(action, topNode, outNode)
344344
self:lookIntoBlock(action, action.keyword[4], blockNode:copy())
345345
local lastAssign = self:getLastAssign(action.start, action.finish)
346346
if lastAssign then
347-
local node = self:getNode(lastAssign)
348-
if node then
349-
topNode = mainNode:merge(node)
350-
end
347+
self:getNode(lastAssign)
348+
end
349+
if self.nodes[action] then
350+
topNode = mainNode:merge(self.nodes[action])
351351
end
352352
end
353353
if action.filter then
@@ -388,11 +388,11 @@ function mt:lookIntoChild(action, topNode, outNode)
388388
else
389389
local lastAssign = self:getLastAssign(subBlock.start, subBlock.finish)
390390
if lastAssign then
391-
local node = self:getNode(lastAssign)
392-
if node then
393-
blockNodes[#blockNodes+1] = node
394-
mergedNode = true
395-
end
391+
self:getNode(lastAssign)
392+
end
393+
if self.nodes[subBlock] then
394+
blockNodes[#blockNodes+1] = self.nodes[subBlock]
395+
mergedNode = true
396396
end
397397
end
398398
end
@@ -461,10 +461,11 @@ function mt:lookIntoBlock(block, start, node)
461461
node = self:lookIntoChild(action, node)
462462
end
463463
if action.finish > start and self.assignMap[action] then
464-
break
464+
return
465465
end
466466
::CONTINUE::
467467
end
468+
self.nodes[block] = node
468469
end
469470

470471
---@param source parser.object

test/type_inference/init.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4080,3 +4080,16 @@ local function x()
40804080
print(<?x?>)
40814081
end
40824082
]]
4083+
4084+
TEST 'number' [[
4085+
---@type number?
4086+
local x
4087+
4088+
do
4089+
if not x then
4090+
return
4091+
end
4092+
end
4093+
4094+
print(<?x?>)
4095+
]]

0 commit comments

Comments
 (0)