Skip to content

Commit

Permalink
[修改] infer长度小于配置N的列表value
Browse files Browse the repository at this point in the history
  • Loading branch information
Rcklos committed Nov 4, 2024
1 parent 69eda2a commit 78530ad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased
<!-- Add all new changes here. They will be moved under a version at release -->
* `FIX` Using variables to retrieve array elements always prompts the first element type
* `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
6 changes: 5 additions & 1 deletion script/vm/type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,10 @@ function vm.getTableValue(uri, tnode, knode, inversion)
end
end
end
local N = config.get(uri, "Lua.type.inferTableSize")
if field.type == 'tableexp'
and field.value then
and field.value
and field.tindex <= N then
if inversion then
if vm.isSubType(uri, 'integer', knode) then
result:merge(vm.compileNode(field.value))
Expand All @@ -666,6 +668,8 @@ function vm.getTableValue(uri, tnode, knode, inversion)
result:merge(vm.compileNode(field.value))
end
end
elseif field.tindex and field.tindex > N then
fprint("field.tindex = %s", field.tindex)
end
if field.type == 'varargs' then
result:merge(vm.compileNode(field))
Expand Down

0 comments on commit 78530ad

Please sign in to comment.