Skip to content

Commit b390ad6

Browse files
committed
first local of for .. in can not be nil
1 parent 7d51c01 commit b390ad6

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

script/vm/compiler.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,9 @@ local compilerSwitch = util.switch()
12281228
for i, loc in ipairs(source.keys) do
12291229
local node = getReturn(source._iterator, i, source._iterArgs)
12301230
if node then
1231+
if i == 1 then
1232+
node:removeOptional()
1233+
end
12311234
vm.setNode(loc, node)
12321235
end
12331236
end

test/type_inference/init.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2048,3 +2048,11 @@ end
20482048
20492049
print(<?x?>)
20502050
]]
2051+
2052+
TEST 'integer' [[
2053+
---@type fun():integer?
2054+
local iter
2055+
2056+
for <?x?> in iter do
2057+
end
2058+
]]

0 commit comments

Comments
 (0)