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 f270a6e

Browse files
authored
Merge branch 'master' into master
2 parents 9a63d2d + c8dd977 commit f270a6e

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
@@ -9,6 +9,8 @@
99
* `ADD` missing locale
1010
* `FIX` updates the EmmyLuaCodeStyle submodule reference to a newer commit, ensuring compatibility with GCC 15
1111
* `CHG` fulfill zh-tw translations
12+
* `FIX` large unions will no longer erroneously fail to match later variants
13+
* `ADD` Lua.type.maxUnionVariants which can be set to limit how many union variants are checked against
1214

1315
## 3.14.0
1416
`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 によって変換されたページ (->オリジナル) /