Skip to content

Commit d4a686e

Browse files
committed
fixup! order of split params
1 parent aa693ca commit d4a686e

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

packages/patterns/src/patterns/patternMatchers.js

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,18 +1263,18 @@ const makePatternKit = () => {
12631263
* @param {CopyArray} elements
12641264
* @param {Pattern} elementPatt
12651265
* @param {bigint} bound Must be >= 1n
1266-
* @param {Checker} check
12671266
* @param {CopyArray} [inResults]
12681267
* @param {CopyArray} [outResults]
1268+
* @param {Checker} [check]
12691269
* @returns {boolean}
12701270
*/
12711271
const elementsHasSplit = (
12721272
elements,
12731273
elementPatt,
12741274
bound,
1275-
check,
12761275
inResults = undefined,
12771276
outResults = undefined,
1277+
check = identChecker,
12781278
) => {
12791279
let count = 0n;
12801280
for (const element of elements) {
@@ -1301,18 +1301,18 @@ const makePatternKit = () => {
13011301
* @param {CopyArray<[Key, bigint]>} pairs
13021302
* @param {Pattern} elementPatt
13031303
* @param {bigint} bound Must be >= 1n
1304-
* @param {Checker} check
13051304
* @param {CopyArray<[Key, bigint]>} [inResults]
13061305
* @param {CopyArray<[Key, bigint]>} [outResults]
13071306
* @returns {boolean}
1307+
* @param {Checker} [check]
13081308
*/
13091309
const pairsHasSplit = (
13101310
pairs,
13111311
elementPatt,
13121312
bound,
1313-
check,
13141313
inResults = undefined,
13151314
outResults = undefined,
1315+
check = identChecker,
13161316
) => {
13171317
let count = 0n;
13181318
for (const [element, num] of pairs) {
@@ -1368,13 +1368,34 @@ const makePatternKit = () => {
13681368
}
13691369
switch (kind) {
13701370
case 'copyArray': {
1371-
return elementsHasSplit(specimen, elementPatt, bound, check);
1371+
return elementsHasSplit(
1372+
specimen,
1373+
elementPatt,
1374+
bound,
1375+
undefined,
1376+
undefined,
1377+
check,
1378+
);
13721379
}
13731380
case 'copySet': {
1374-
return elementsHasSplit(specimen.payload, elementPatt, bound, check);
1381+
return elementsHasSplit(
1382+
specimen.payload,
1383+
elementPatt,
1384+
bound,
1385+
undefined,
1386+
undefined,
1387+
check,
1388+
);
13751389
}
13761390
case 'copyBag': {
1377-
return pairsHasSplit(specimen.payload, elementPatt, bound, check);
1391+
return pairsHasSplit(
1392+
specimen.payload,
1393+
elementPatt,
1394+
bound,
1395+
undefined,
1396+
undefined,
1397+
check,
1398+
);
13781399
}
13791400
default: {
13801401
return check(false, X`unexpected ${q(kind)}`);

packages/patterns/test/patterns.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,10 +882,12 @@ test('well formed patterns', t => {
882882
t.throws(() => M.has('c', 0n), {
883883
message: 'match:has payload: [1]: "[0n]" - Must be >= "[1n]"',
884884
});
885+
// @ts-expect-error purposeful type violation for testing
885886
t.throws(() => M.has('c', M.nat()), {
886887
message:
887888
'match:has payload: [1]: A passable tagged "match:nat" is not a key: "[match:nat]"',
888889
});
890+
// @ts-expect-error purposeful type violation for testing
889891
t.throws(() => M.has(3, 1), {
890892
message: 'match:has payload: [1]: 1 - Must be >= "[1n]"',
891893
});

0 commit comments

Comments
 (0)