Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 56a80a3

Browse files
fix: large unions no longer erroneously fail to match later variants
1 parent 119355c commit 56a80a3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

‎changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* `FIX` Prevent class methods from triggering missing-fields diagnostics
99
* `ADD` missing locale
1010
* `FIX` updates the EmmyLuaCodeStyle submodule reference to a newer commit, ensuring compatibility with GCC 15
11+
* `FIX` large unions will no longer erroneously fail to match later variants
12+
* `ADD` Lua.type.maxUnionVariants which can be set to limit how many union variants are checked against
1113

1214
## 3.14.0
1315
`2025年4月7日`

‎script/config/template.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ local template = {
401401
['Lua.language.completeAnnotation'] = Type.Boolean >> true,
402402
['Lua.type.castNumberToInteger'] = Type.Boolean >> true,
403403
['Lua.type.weakUnionCheck'] = Type.Boolean >> false,
404+
['Lua.type.maxUnionVariants'] = Type.Integer >> 0,
404405
['Lua.type.weakNilCheck'] = Type.Boolean >> false,
405406
['Lua.type.inferParamType'] = Type.Boolean >> false,
406407
['Lua.type.checkTableShape'] = Type.Boolean >> false,

‎script/vm/type.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,10 +374,11 @@ function vm.isSubType(uri, child, parent, mark, errs)
374374
elseif child.type == 'vm.node' then
375375
if config.get(uri, 'Lua.type.weakUnionCheck') then
376376
local hasKnownType = 0
377+
local maxUnionVariants = config.get(uri, 'Lua.type.maxUnionVariants') or 0
377378
local i = 0
378379
for n in child:eachObject() do
379380
i = i + 1
380-
if i > 100 then
381+
if maxUnionVariants>0andi > maxUnionVariants then
381382
break
382383
end
383384
if vm.getNodeName(n) then
@@ -403,10 +404,11 @@ function vm.isSubType(uri, child, parent, mark, errs)
403404
else
404405
local weakNil = config.get(uri, 'Lua.type.weakNilCheck')
405406
local skipTable
407+
local maxUnionVariants = config.get(uri, 'Lua.type.maxUnionVariants') or 0
406408
local i = 0
407409
for n in child:eachObject() do
408410
i = i + 1
409-
if i > 100 then
411+
if maxUnionVariants>0andi > maxUnionVariants then
410412
break
411413
end
412414
if skipTable == nil and n.type == "table" and parent.type == "vm.node" then -- skip table type check if child has class
@@ -473,10 +475,11 @@ function vm.isSubType(uri, child, parent, mark, errs)
473475
parent = global
474476
elseif parent.type == 'vm.node' then
475477
local hasKnownType = 0
478+
local maxUnionVariants = config.get(uri, 'Lua.type.maxUnionVariants') or 0
476479
local i = 0
477480
for n in parent:eachObject() do
478481
i = i + 1
479-
if i > 100 then
482+
if maxUnionVariants>0andi > maxUnionVariants then
480483
break
481484
end
482485
if vm.getNodeName(n) then

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /