Skip to content

Commit

Permalink
fix: consider varargs the same as tableexp for iterating (#2906)
Browse files Browse the repository at this point in the history
Co-authored-by: Tom Lau <tomandfatboy@gmail.com>
  • Loading branch information
PennyJim and tomlau10 committed Oct 23, 2024
1 parent b815469 commit 482052b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` A regression related to type narrow and generic param introduced since `v3.10.1`
* `FIX` Determine that the index of `{...}` is an integer when iterating

## 3.11.1
`2024-10-9`
Expand Down
2 changes: 1 addition & 1 deletion script/vm/type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ function vm.getTableKey(uri, tnode, vnode, reverse)
if field.type == 'tablefield' then
result:merge(vm.declareGlobal('type', 'string'))
end
if field.type == 'tableexp' then
if field.type == 'tableexp' or field.type == 'varargs' then
result:merge(vm.declareGlobal('type', 'integer'))
end
end
Expand Down
8 changes: 8 additions & 0 deletions test/type_inference/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4591,3 +4591,11 @@ local function f(v) end
local <?r?> = f('')
]]

TEST 'integer' [[
local function F(...)
local t = {...}
for <?k?> in pairs(t) do
end
end
]]

0 comments on commit 482052b

Please sign in to comment.