Skip to content

Commit

Permalink
Merge pull request #2956 from d-enk/fix-check-vm-type-nil-errs
Browse files Browse the repository at this point in the history
fix: add missing `errs ~= nil` checks to script/vm/type checkTableShape
  • Loading branch information
sumneko authored Nov 15, 2024
2 parents a028465 + 7e11f26 commit db8127a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

## 3.13.1
Expand Down
10 changes: 6 additions & 4 deletions script/vm/type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ local function checkTableShape(parent, child, uri, mark, errs)
if myKeys[key] then
ok = vm.isSubType(uri, myKeys[key], nodeField, mark, errs)
if ok == false then
errs[#errs+1] = 'TYPE_ERROR_PARENT_ALL_DISMATCH' -- error display can be greatly improved
errs[#errs+1] = myKeys[key]
errs[#errs+1] = nodeField
if errs then
errs[#errs+1] = 'TYPE_ERROR_PARENT_ALL_DISMATCH' -- error display can be greatly improved
errs[#errs+1] = myKeys[key]
errs[#errs+1] = nodeField
end
failedCheck = true
end
elseif not nodeField:isNullable() then
Expand All @@ -337,7 +339,7 @@ local function checkTableShape(parent, child, uri, mark, errs)
end
::continue::
end
if #missedKeys > 0 then
if errs and #missedKeys > 0 then
errs[#errs+1] = 'DIAG_MISSING_FIELDS'
errs[#errs+1] = parent
errs[#errs+1] = table.concat(missedKeys, ', ')
Expand Down

0 comments on commit db8127a

Please sign in to comment.