Skip to content

fix(diagnostics): MAP signature checks read |-continued signatures whole - #851

Closed
geircodes wants to merge 1 commit into
msarson:version-1.0.10from
geircodes:fix/map-signature-continuation-lines
Closed

geircodes wants to merge 1 commit into
msarson:version-1.0.10from
geircodes:fix/map-signature-continuation-lines

Conversation

@geircodes

Copy link
Copy Markdown
Contributor

What happens

A MAP prototype continued with |, implemented on one line:

  MAP
    MODULE('member.clw')
MyProc   PROCEDURE(*SomeClass pObj, STRING pName, STRING pValue, |
                   *CSTRING pOut),LONG
    END
  END
  MEMBER('parent.clw')

MyProc PROCEDURE(*SomeClass pObj, STRING pName, STRING pValue, *CSTRING pOut)

The two signatures are identical, but the implementation gets
Procedure 'MyProc' signature does not match its MAP declaration.

The opposite shape is worse: when both sides are continued, a real mismatch after the
break is never reported.

Root cause

MapDeclarationDiagnostics reads each signature from its first line only:

const declLine = docLines[selfModuleDecl.line] ?? '';
const implLine = docLines[proc.line] ?? '';
const declParams = ProcedureSignatureUtils.extractParameterTypes(declLine);

ProcedureSignatureUtils.splitParameters matches PROCEDURE\s*\(([^)]*)\). On a line ending
in | there is no closing ), so the parameter list reads as empty. That gives:

  • one side continued: n parameters vs 0, a false map-signature-mismatch (and the same
    for map-impl-signature-mismatch on the PROGRAM side);
  • both sides continued: 0 vs 0, always a match, so a real mismatch goes unreported;
  • ,DLL on a continuation line: the ,DLL test in validateMissingImplementations reads
    the first line too, misses the attribute, and reports the external prototype as
    missing-map-implementation.

Fix

All eleven line reads in the file go through one helper, which joins the continuation lines
with the existing withContinuations() from ClassMemberScan (added for #778 for the same
reason on CLASS members):

function logicalLine(lines: string[], k: number): string {
    return lines[k] === undefined ? '' : withContinuations(lines, k);
}
const declLine = logicalLine(docLines, selfModuleDecl.line);
const implLine = logicalLine(docLines, proc.line);

That covers Cases 1, 2 and 2c, the cross-file branch of validateMissingMapDeclarations, and the
signature compare and the ,DLL check in validateMissingImplementations. A line without a
trailing | is returned unchanged, so single-line signatures behave exactly as before.

Testing

New server/src/test/MapSignatureContinuation.test.ts, 9 tests:

Case Expected
continued prototype, one-line implementation no diagnostic
same, CRLF line endings no diagnostic
one-line prototype, continued implementation (comment before the |) no diagnostic
both continued, same parameters no diagnostic
both continued, a parameter differs after the break map-signature-mismatch
self-declared MODULE in the member's own MAP, continued prototype no diagnostic
PROGRAM side: continued prototype, one-line implementation no diagnostic
PROGRAM side: both continued, a parameter differs map-impl-signature-mismatch
PROGRAM side: ,DLL(1) on the continuation line no diagnostic

With MapDeclarationDiagnostics.ts reverted to the base, 8 of the 9 fail. The remaining one
(both continued, same parameters) passed before only because both sides read as empty.

Server suite: 4513 passing, 3 pending, 0 failing.

Scope

Left out on purpose:

  • The quick fixes in MapDeclarationCodeActionProvider ("Update declaration/implementation
    to match") still work on one line: findParameterListSpan finds no closed list on a
    continued line, so no action is offered. Nothing gets broken, but no fix is offered either.
    Rewriting a parameter list across several lines needs a multi-line edit range. That is a
    separate change, which I can follow up on if wanted.
  • ProcedureSignatureUtils itself is unchanged. The callers decide which text is the
    signature, as the other withContinuations callers in MemberLocatorService already do.

map-signature-mismatch and map-impl-signature-mismatch compared the first
line of a MAP prototype with the first line of its PROCEDURE. A signature
continued with `|` has no closing `)` on that line, so its parameter list
read as empty:

- continued on one side only: a false mismatch (n parameters vs 0);
- continued on both sides: always a "match", so a real mismatch after the
  break went unreported.

The same first-line read hid a `,DLL` attribute on a continuation line, and
missing-map-implementation reported the external prototype as unimplemented.

Every line read in MapDeclarationDiagnostics now goes through a
logicalLine() helper that joins the continuation lines with the existing
withContinuations() (ClassMemberScan, msarson#778).

New MapSignatureContinuation.test.ts (9 tests): one side continued (LF and
CRLF), both sides continued with equal and with differing parameters, a
self-declared MODULE in the member's own MAP, the PROGRAM-side check, and
`,DLL` on a continuation line. Without the fix 8 of the 9 fail; the
remaining one (both continued, equal parameters) passed vacuously before.

Server suite: 4513 passing, 3 pending, 0 failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msarson

msarson commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Thanks, this is going into 1.0.10. Your commit is unchanged; I added three on top:

  • a CHANGELOG entry under Diagnostics;
  • two more tests, for the two reads no test reached: a continued prototype in a procedure-local MAP, and one in a bare MAP entry. Each sets a mismatch after the break; both fail without your fix and pass with it;
  • a rename of the test file to MapDeclaration.SignatureContinuation851.test.ts, so it is named like its neighbours.

Yes please to the follow-up you offered: the "Update declaration/implementation to match" quick fixes for a signature continued with |. That can go into 1.0.11.

— Alice

msarson added a commit that referenced this pull request Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
msarson added a commit that referenced this pull request Nov 3, 2026
…otype

The review found Cases 2 and 2c (four of the eleven reads) reached by no
test. Both continued, a parameter differing after the break: reported with
the fix, missed without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
msarson added a commit that referenced this pull request Nov 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@msarson

msarson commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Merged into version-1.0.10 as 58afb50 (your commit, replayed onto the current tip, so the hash changed), with the follow-ups in 819d35c, 5472d06 and 8a6e7ac. Pushed.

@msarson msarson closed this Nov 3, 2026
@geircodes
geircodes deleted the fix/map-signature-continuation-lines branch November 25, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants