summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/vm/compiler.lua3
-rw-r--r--test/type_inference/init.lua8
2 files changed, 11 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 5a30367a..c7d559b5 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -1228,6 +1228,9 @@ local compilerSwitch = util.switch()
for i, loc in ipairs(source.keys) do
local node = getReturn(source._iterator, i, source._iterArgs)
if node then
+ if i == 1 then
+ node:removeOptional()
+ end
vm.setNode(loc, node)
end
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index 243eb218..974e3f73 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -2048,3 +2048,11 @@ end
print(<?x?>)
]]
+
+TEST 'integer' [[
+---@type fun():integer?
+local iter
+
+for <?x?> in iter do
+end
+]]