DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B1015: body does not match its declaration

Catalog status: active. Default severity: error. Stable name: nonconforming-body. Family: Names and declarations.

A subprogram body must conform to its separate declaration: the same parameter names, modes and types, and the same result type (Ada RM 6.3.1). When a body completes a separate declaration, its Pre and Post belong on that declaration. A standalone body that also declares the operation can carry its own contracts in their supported source position.

Example (Vada)

   procedure Scale (Factor : Integer);          --  in the spec
   procedure Scale (Ratio : Integer) is ...     --  in the body

Example (Varc)

    pub fn scale(factor: Integer);       // the declaration
    fn scale(ratio: Integer) { ... }     // its body

What to do

Make the body's profile repeat the separate declaration's exactly, and move its Pre/Post contracts to that interface declaration when one exists.

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See names and declarations, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.