From a4a9ebdc2e214fddd006f538ef27550b5e57a541 Mon Sep 17 00:00:00 2001
From: Kevin Gibbons <bakkot@gmail.com>
Date: Mon, 17 Oct 2022 14:30:30 -0700
Subject: [PATCH] do not include deleted params in header signature (#492)

---
 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("<del>'d params don't contribute to signature", async () => {
+    let biblio = await getBiblio(`
+      <emu-clause id="del-complex" type="abstract operation">
+        <h1>
+        DelExample (
+            <del>_x_: unknown,</del>
+            _y_: unknown,
+            <ins>_z_: unknown,</ins>
+            <ins>_w_: unknown,</ins>
+          ): unknown
+        </h1>
+        <dl class="header"></dl>
+      </emu-clause>
+    `);
+
+    await assertLint(
+      positioned`
+        <emu-alg>
+          1. Return ${M}DelExample(*"x"*, *"y"*).
+        </emu-alg>
+      `,
+      {
+        ruleId: 'typecheck',
+        nodeType: 'emu-alg',
+        message: 'DelExample takes 3 arguments, but this invocation passes 2',
+      },
+      {
+        extraBiblios: [biblio],
+      }
+    );
+
+    await assertLintFree(
+      `
+        <emu-alg>
+          1. Return DelExample(*"y"*, *"z"*, *"w"*).
+        </emu-alg>
+      `,
+      {
+        extraBiblios: [biblio],
+      }
+    );
+  });
+
   it('negative', async () => {
     await assertLintFree(
       `