Skip to content

Commit db8127a

Browse files
authored
Merge pull request #2956 from d-enk/fix-check-vm-type-nil-errs
fix: add missing `errs ~= nil` checks to script/vm/type checkTableShape
2 parents a028465 + 7e11f26 commit db8127a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `FIX` Add missing `errs ~= nil` checks to script/vm/type checkTableShape
56
* `CHG` fulfill zh-cn translations
67

78
## 3.13.1

script/vm/type.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,11 @@ local function checkTableShape(parent, child, uri, mark, errs)
321321
if myKeys[key] then
322322
ok = vm.isSubType(uri, myKeys[key], nodeField, mark, errs)
323323
if ok == false then
324-
errs[#errs+1] = 'TYPE_ERROR_PARENT_ALL_DISMATCH' -- error display can be greatly improved
325-
errs[#errs+1] = myKeys[key]
326-
errs[#errs+1] = nodeField
324+
if errs then
325+
errs[#errs+1] = 'TYPE_ERROR_PARENT_ALL_DISMATCH' -- error display can be greatly improved
326+
errs[#errs+1] = myKeys[key]
327+
errs[#errs+1] = nodeField
328+
end
327329
failedCheck = true
328330
end
329331
elseif not nodeField:isNullable() then
@@ -337,7 +339,7 @@ local function checkTableShape(parent, child, uri, mark, errs)
337339
end
338340
::continue::
339341
end
340-
if #missedKeys > 0 then
342+
if errs and #missedKeys > 0 then
341343
errs[#errs+1] = 'DIAG_MISSING_FIELDS'
342344
errs[#errs+1] = parent
343345
errs[#errs+1] = table.concat(missedKeys, ', ')

0 commit comments

Comments
 (0)