Skip to content

Commit

Permalink
fix: lax arity of returns in function literals
Browse files Browse the repository at this point in the history
The unwanted difference between the types for `f` and `g` in
the regression test from this commit was observed when fixing
the issue #736.
  • Loading branch information
hishamhm committed May 10, 2024
1 parent 71b635c commit dfa8f6b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions spec/lax/lax_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,27 @@ describe("lax mode", function()
{ msg = "three" },
{ msg = "data" },
}))

it("defines lax arity of returns in function literals (#736)", util.lax_check([[
-- f: function(unknown...):unknown...
local f = function()
return function() end
end
for a, b in f() do
end
-- g: function(unknown...):unknown...
local function g()
return function() end
end
for x, y in g() do
end
]], {
{ msg = "a" },
{ msg = "b" },
{ msg = "x" },
{ msg = "y" },
}))
end)
2 changes: 1 addition & 1 deletion tl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11373,7 +11373,7 @@ self:expand_type(node, values, elements) })
min_arity = node.min_arity,
typeargs = node.typeargs,
args = args,
rets = rets,
rets = self.get_rets(rets),
}))
end,
},
Expand Down
2 changes: 1 addition & 1 deletion tl.tl
Original file line number Diff line number Diff line change
Expand Up @@ -11373,7 +11373,7 @@ do
min_arity = node.min_arity,
typeargs = node.typeargs,
args = args,
rets = rets,
rets = self.get_rets(rets),
}))
end,
},
Expand Down

0 comments on commit dfa8f6b

Please sign in to comment.