Skip to content

Commit

Permalink
Merge branch 'master' into enum
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko authored Oct 28, 2024
2 parents 8a99135 + 575e524 commit b3b1bf6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 5 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<!-- 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`
* `New` Support importing `enum` through class name suffix matching in quick fixes, allowing the import of `enum` from `table.table.enum; return table`.
* `FIX` Parse storagePath to improve reliability of resolving ${addons} placeholder
* `FIX` Reference should also look in tablefield
* `FIX` Determine that the index of `{...}` is an integer when iterating

## 3.11.1
`2024-10-9`
Expand Down
6 changes: 3 additions & 3 deletions script/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -919,10 +919,10 @@ function m.resolvePathPlaceholders(path)
if addonsPath then
return addonsPath
end
local client = require 'client'
local storagePath = client.getOption('storagePath')
local client = require("client")
local storagePath = client.getOption("storagePath")
if storagePath then
addonsPath = storagePath .. "/addonManager/addons"
addonsPath = (fs.path(storagePath) / "addonManager" / "addons"):string()
else
-- Common path across OSes
local dataPath = "User/globalStorage/sumneko.lua/addonManager/addons"
Expand Down
2 changes: 1 addition & 1 deletion script/vm/ref.lua
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ local function searchWord(source, pushResult, defMap, fileNotify)
end)
end
---@async
guide.eachSourceTypes(state.ast, {'getfield', 'setfield'}, function (src)
guide.eachSourceTypes(state.ast, {'getfield', 'setfield', 'tablefield'}, function (src)
if src.field and src.field[1] == key then
checkDef(src)
await.delay()
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
10 changes: 10 additions & 0 deletions test/references/all.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,13 @@ function TestB(param)
param:<!TestA!>()
end
]]

TEST [[
---@class A
---@field <~x~> number
---@type A
local t = {
<!x!> = 1
}
]]
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 b3b1bf6

Please sign in to comment.