From b3c9fb494c52b9660db19b1d3eefbdfee577b9e0 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 17 Oct 2022 14:25:10 -0700 Subject: [PATCH] do not include deleted params in header signature --- src/Clause.ts | 20 ++++++++++++-------- test/typecheck.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/Clause.ts b/src/Clause.ts index bab8dd81..2d8d0596 100644 --- a/src/Clause.ts +++ b/src/Clause.ts @@ -402,14 +402,18 @@ function parseType(type: string, offset: number): Type { function parsedHeaderToSignature(parsedHeader: ParsedHeader): Signature { const ret = { - parameters: parsedHeader.params.map(p => ({ - name: p.name, - type: p.type == null ? null : parseType(p.type, p.typeOffset), - })), - optionalParameters: parsedHeader.optionalParams.map(p => ({ - name: p.name, - type: p.type == null ? null : parseType(p.type, p.typeOffset), - })), + parameters: parsedHeader.params + .filter(p => p.wrappingTag !== 'del') + .map(p => ({ + name: p.name, + type: p.type == null ? null : parseType(p.type, p.typeOffset), + })), + optionalParameters: parsedHeader.optionalParams + .filter(p => p.wrappingTag !== 'del') + .map(p => ({ + name: p.name, + type: p.type == null ? null : parseType(p.type, p.typeOffset), + })), return: parsedHeader.returnType == null ? null diff --git a/test/typecheck.js b/test/typecheck.js index 183331af..0d9ed66f 100644 --- a/test/typecheck.js +++ b/test/typecheck.js @@ -846,6 +846,49 @@ describe('signature agreement', async () => { ); }); + it("'d params don't contribute to signature", async () => { + let biblio = await getBiblio(` + +

+ DelExample ( + _x_: unknown, + _y_: unknown, + _z_: unknown, + _w_: unknown, + ): unknown +

+
+
+ `); + + await assertLint( + positioned` + + 1. Return ${M}DelExample(*"x"*, *"y"*). + + `, + { + ruleId: 'typecheck', + nodeType: 'emu-alg', + message: 'DelExample takes 3 arguments, but this invocation passes 2', + }, + { + extraBiblios: [biblio], + } + ); + + await assertLintFree( + ` + + 1. Return DelExample(*"y"*, *"z"*, *"w"*). + + `, + { + extraBiblios: [biblio], + } + ); + }); + it('negative', async () => { await assertLintFree( `