Skip to content

Commit

Permalink
Merge pull request #2908 from PennyJim/unknown-vararg-itter-index
Browse files Browse the repository at this point in the history
Fix vararg indices being unknown when iterated
  • Loading branch information
sumneko authored Oct 28, 2024
2 parents b815469 + 482052b commit efebc97
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 efebc97

Please sign in to comment.