@@ -327,7 +327,7 @@ function vm.isSubType(uri, child, parent, mark, errs)
327
327
local weakNil = config .get (uri , ' Lua.type.weakNilCheck' )
328
328
local skipTable
329
329
for n in child :eachObject () do
330
- if skipTable == nil and n .type == " table" and parent .type == " vm.node" then -- skip table type check if child is has class
330
+ if skipTable == nil and n .type == " table" and parent .type == " vm.node" then -- skip table type check if child has class
331
331
--- @cast parent vm.node
332
332
for _ , c in ipairs (child ) do
333
333
if c .type == ' global' and c .cate == ' type' then
@@ -486,19 +486,20 @@ function vm.isSubType(uri, child, parent, mark, errs)
486
486
local set = parent :getSets (uri )
487
487
local missedKeys = {}
488
488
local failedCheck
489
-
490
- local myKeys = {}
491
- for _ , field in ipairs (child ) do
492
- local key = vm .getKeyName (field ) or field .tindex
493
- if key then
494
- myKeys [key ] = vm .compileNode (field )
495
- end
496
- end
497
-
489
+ local myKeys
498
490
for _ , def in ipairs (set ) do
499
491
if not def .fields or # def .fields == 0 then
500
492
goto continue
501
493
end
494
+ if not myKeys then
495
+ myKeys = {}
496
+ for _ , field in ipairs (child ) do
497
+ local key = vm .getKeyName (field ) or field .tindex
498
+ if key then
499
+ myKeys [key ] = vm .compileNode (field )
500
+ end
501
+ end
502
+ end
502
503
503
504
for _ , field in ipairs (def .fields ) do
504
505
local key = vm .getKeyName (field )
@@ -512,6 +513,7 @@ function vm.isSubType(uri, child, parent, mark, errs)
512
513
if not key then
513
514
goto continue
514
515
end
516
+
515
517
local ok
516
518
local nodeField = vm .compileNode (field )
517
519
if myKeys [key ] then
0 commit comments