Skip to content

Commit 98fe538

Browse files
committed
fix
1 parent ed2fd90 commit 98fe538

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

script/vm/runner.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ end
114114
---@param outNode? vm.node
115115
---@return vm.node
116116
function mt:_lookInto(action, topNode, outNode)
117+
if not action then
118+
return topNode, outNode
119+
end
117120
local set
118121
local value = vm.getObjectValue(action)
119122
if value then
@@ -128,7 +131,9 @@ function mt:_lookInto(action, topNode, outNode)
128131
self:_launchBlock(action, topNode:copy())
129132
elseif action.type == 'while' then
130133
local blockNode, mainNode = self:_lookInto(action.filter, topNode:copy(), topNode:copy())
131-
self:_fastWard(action.filter.finish, blockNode)
134+
if action.filter then
135+
self:_fastWard(action.filter.finish, blockNode)
136+
end
132137
self:_launchBlock(action, blockNode:copy())
133138
topNode = mainNode
134139
elseif action.type == 'if' then
@@ -201,7 +206,7 @@ function mt:_lookInto(action, topNode, outNode)
201206
end
202207
end
203208
if loc then
204-
self:_fastWard(loc.finish, topNode)
209+
self:_fastWard(loc.finish, topNode:copy())
205210
if guide.isLiteral(checker) then
206211
local checkerNode = vm.compileNode(checker)
207212
if action.op.type == '==' then

test/type_inference/init.lua

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2512,3 +2512,39 @@ TEST 'fun(x: fun(x: unknown))' [[
25122512
---@type xxx
25132513
local <?t?>
25142514
]]
2515+
2516+
TEST 'table' [[
2517+
---@type table|nil
2518+
local t
2519+
2520+
while t do
2521+
print(<?t?>)
2522+
end
2523+
]]
2524+
2525+
TEST 'table|nil' [[
2526+
---@type table|nil
2527+
local t
2528+
2529+
while <?t?> do
2530+
print(t)
2531+
end
2532+
]]
2533+
2534+
TEST 'table' [[
2535+
---@type table|nil
2536+
local t
2537+
2538+
while t ~= nil do
2539+
print(<?t?>)
2540+
end
2541+
]]
2542+
2543+
TEST 'table|nil' [[
2544+
---@type table|nil
2545+
local t
2546+
2547+
while <?t?> ~= nil do
2548+
print(t)
2549+
end
2550+
]]

0 commit comments

Comments
 (0)