From 8cea5ce026c22cab3581d87d6b9b69a7ed7f828e Mon Sep 17 00:00:00 2001 From: "Mark S. Miller" Date: Tue, 12 Sep 2023 20:48:25 -0700 Subject: [PATCH] fix: review suggestions --- packages/exo/src/exo-tools.js | 5 +++-- packages/exo/test/test-heap-classes.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/exo/src/exo-tools.js b/packages/exo/src/exo-tools.js index d02f51fe06..574ec9075f 100644 --- a/packages/exo/src/exo-tools.js +++ b/packages/exo/src/exo-tools.js @@ -35,11 +35,11 @@ const MinMethodGuard = M.call().rest(M.any()).returns(M.any()); /** * @param {Passable[]} args * @param {MethodGuardPayload} methodGuardPayload - * @param {string | undefined} label + * @param {string} [label] * @returns {Passable[]} Returns the args that should be passed to the * raw method */ -const defendSyncArgs = (args, methodGuardPayload, label) => { +const defendSyncArgs = (args, methodGuardPayload, label = undefined) => { const { argGuards, optionalArgGuards, restArgGuard } = methodGuardPayload; const paramsPattern = M.splitArray( argGuards, @@ -55,6 +55,7 @@ const defendSyncArgs = (args, methodGuardPayload, label) => { if (args.length <= declaredLen) { return args; } + // Ignore extraneous arguments, as a JS function call would do. return args.slice(0, declaredLen); }; diff --git a/packages/exo/test/test-heap-classes.js b/packages/exo/test/test-heap-classes.js index 73d33b14ac..8f5e753a92 100644 --- a/packages/exo/test/test-heap-classes.js +++ b/packages/exo/test/test-heap-classes.js @@ -20,7 +20,7 @@ test('what happens with extra arguments', t => { t.is(x, undefined); }, }); - exo.foo(8); + exo.foo('an extra arg'); }); const UpCounterI = M.interface('UpCounter', {