Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/patterns/src/patterns/patternMatchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ const makePatternKit = () => {
let style;
switch (kind) {
case 'copySet':
case 'copyBag':
case 'copyMap': {
style = 'tagged';
break;
Expand Down
22 changes: 21 additions & 1 deletion packages/patterns/test/patterns.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
isKey,
assertKey,
} from '../src/keys/checkKey.js';
import { mustMatch, matches, M } from '../src/patterns/patternMatchers.js';
import {
mustMatch,
matches,
M,
getRankCover,
} from '../src/patterns/patternMatchers.js';

const { stringify: q } = JSON;

Expand Down Expand Up @@ -971,3 +976,18 @@ test('Far functions (callable remotables) are valid Keys', t => {
const set = makeCopySet([farFn]);
t.true(matches(set, M.set()));
});

test('getRankCover treats copyBag like other tagged kinds (#3052)', t => {
// copySet, copyBag, and copyMap all encode as the 'tagged' pass style,
// so getRankCover must produce the same range for each. Previously
// copyBag fell through to the default branch and threw a TypeError
// because 'copyBag' is not a known PassStyle.
// The kind matcher's getRankCover does not consult encodePassable, so
// this test does not require a real encoder.
const stubEncode = () => '';
const setCover = getRankCover(M.kind('copySet'), stubEncode);
const bagCover = getRankCover(M.kind('copyBag'), stubEncode);
const mapCover = getRankCover(M.kind('copyMap'), stubEncode);
t.deepEqual(bagCover, setCover);
t.deepEqual(bagCover, mapCover);
});
Loading