Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix table array infer #2924

Merged
merged 7 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `NEW` Setting: `Lua.type.inferTableSize`: A Small Table array can be infered

## 3.12.0
`2024-10-30`
Expand Down
1 change: 1 addition & 0 deletions script/config/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ local template = {
['Lua.type.weakNilCheck'] = Type.Boolean >> false,
['Lua.type.inferParamType'] = Type.Boolean >> false,
['Lua.type.checkTableShape'] = Type.Boolean >> false,
['Lua.type.inferTableSize'] = Type.Integer >> 10,
['Lua.doc.privateName'] = Type.Array(Type.String),
['Lua.doc.protectedName'] = Type.Array(Type.String),
['Lua.doc.packageName'] = Type.Array(Type.String),
Expand Down
3 changes: 2 additions & 1 deletion script/vm/type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@ end
---@return vm.node?
function vm.getTableValue(uri, tnode, knode, inversion)
local result = vm.createNode()
local inferSize = config.get(uri, "Lua.type.inferTableSize")
for tn in tnode:eachObject() do
if tn.type == 'doc.type.table' then
for _, field in ipairs(tn.fields) do
Expand Down Expand Up @@ -657,7 +658,7 @@ function vm.getTableValue(uri, tnode, knode, inversion)
end
if field.type == 'tableexp'
and field.value
and field.tindex == 1 then
and field.tindex <= inferSize then
if inversion then
if vm.isSubType(uri, 'integer', knode) then
result:merge(vm.compileNode(field.value))
Expand Down
Loading