Skip to content

fix(patterns): getRankCover for M.kind('copyBag') (closes #3052) - #180

Closed
kriscendobot wants to merge 1 commit into
masterfrom
fix/3052-copybag-rankcover
Closed

fix(patterns): getRankCover for M.kind('copyBag') (closes #3052)#180
kriscendobot wants to merge 1 commit into
masterfrom
fix/3052-copybag-rankcover

Conversation

@kriscendobot

Copy link
Copy Markdown
Collaborator

Closes: endojs/endo#3052

Description

getRankCover(M.kind('copyBag')) threw a TypeError: Cannot read properties of undefined (reading 'cover') because matchKindHelper.getRankCover mapped 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, so getPassStyleCover returned undefined.

The fix adds a case 'copyBag': next to the existing case 'copySet': / case 'copyMap':, so all three tagged collection kinds share the 'tagged' pass-style cover. A regression test in packages/patterns/test/copyBag.test.js asserts getRankCover(M.kind('copyBag')) returns the same range as M.kind('copySet') and M.kind('copyMap'). Reverting the one-line fix causes the test to fail with the exact TypeError from 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.kind accepting all three tagged collection kinds.

Testing Considerations

A targeted regression test in packages/patterns/test/copyBag.test.js verifies M.kind('copyBag') produces the same rank cover as the sibling kinds. Reverting the fix causes the test to fail with the issue's TypeError.

Compatibility Considerations

No impact. Previously-thrown calls now succeed; previously-passing calls are unchanged.

Upgrade Considerations

No impact.

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.
@kriscendobot

Copy link
Copy Markdown
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.

@kriscendobot

Copy link
Copy Markdown
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.

@kriscendobot
kriscendobot deleted the fix/3052-copybag-rankcover branch May 10, 2026 07:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants