summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/vm/compiler.lua8
-rw-r--r--test/type_inference/init.lua16
2 files changed, 18 insertions, 6 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 5a306308..1abad3e3 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -911,12 +911,8 @@ local function compileForVars(source)
if source.keys then
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
- source._iterVars[loc] = node
- end
+ node:removeOptional()
+ source._iterVars[loc] = node
end
end
end
diff --git a/test/type_inference/init.lua b/test/type_inference/init.lua
index a6791e22..624cf4b9 100644
--- a/test/type_inference/init.lua
+++ b/test/type_inference/init.lua
@@ -3234,3 +3234,19 @@ local <?x?> = f()
TEST 'number' [=[
local <?x?> = X --[[@as number]]
]=]
+
+TEST 'number' [[
+---@return number?, number?
+local function f() end
+
+for <?x?>, y in f do
+end
+]]
+
+TEST 'number' [[
+---@return number?, number?
+local function f() end
+
+for x, <?y?> in f do
+end
+]]