fix(patterns): getRankCover for M.kind('copyBag') (closes #3052) - #180
Closed
kriscendobot wants to merge 1 commit into
Closed
fix(patterns): getRankCover for M.kind('copyBag') (closes #3052)#180kriscendobot wants to merge 1 commit into
kriscendobot wants to merge 1 commit into
Conversation
The matchKindHelper.getRankCover switch handled 'copySet' and 'copyMap'
explicitly but fell through to the default for 'copyBag'. The default
treats the kind as a pass style and looks up its cover in the pass-style
table; 'copyBag' has no entry there, so getPassStyleCover returned
undefined and the next access ('cover') threw a TypeError.
Add 'copyBag' to the same case as 'copySet' and 'copyMap' so all three
tagged collection kinds share the 'tagged' pass-style cover.
Collaborator
Author
|
Implements the fix from the agent-ready plan for endojs/endo#3052: add 'copyBag' to the matchKindHelper switch alongside 'copySet' and 'copyMap'. Regression test in packages/patterns/test/copyBag.test.js fails with the issue's TypeError when the new case is reverted. |
Collaborator
Author
|
Duplicates upstream endojs/endo#3228 (OPEN, awaiting review), which has the same one-line fix and a regression test. The earlier bots-repo attempt #65 was already closed without merge in favor of the upstream PR. Closing in favor of #3228. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: endojs/endo#3052
Description
getRankCover(M.kind('copyBag'))threw aTypeError: Cannot read properties of undefined (reading 'cover')becausematchKindHelper.getRankCovermapped only'copySet'and'copyMap'to the'tagged'pass style;'copyBag'fell through to the default branch, which looked up the kind directly in the pass-style cover table. There is no'copyBag'pass style, sogetPassStyleCoverreturnedundefined.The fix adds a
case 'copyBag':next to the existingcase 'copySet':/case 'copyMap':, so all three tagged collection kinds share the'tagged'pass-style cover. A regression test inpackages/patterns/test/copyBag.test.jsassertsgetRankCover(M.kind('copyBag'))returns the same range asM.kind('copySet')andM.kind('copyMap'). Reverting the one-line fix causes the test to fail with the exactTypeErrorfrom the issue.Security Considerations
No impact. The change broadens which inputs are accepted by an existing rank-cover lookup; no new authority is introduced.
Scaling Considerations
No impact. One added switch case, evaluated at pattern-match time only.
Documentation Considerations
No impact. The fix restores the documented behavior implied by
M.kindaccepting all three tagged collection kinds.Testing Considerations
A targeted regression test in
packages/patterns/test/copyBag.test.jsverifiesM.kind('copyBag')produces the same rank cover as the sibling kinds. Reverting the fix causes the test to fail with the issue'sTypeError.Compatibility Considerations
No impact. Previously-thrown calls now succeed; previously-passing calls are unchanged.
Upgrade Considerations
No impact.