DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B2010: aggregate does not match its type

Catalog status: active. Default severity: error. Stable name: invalid-aggregate. Family: Types and constraints.

An aggregate gives a value for every component of a record (or every element of an array), each exactly once. Its type comes from the context; where the context does not determine it, qualify the aggregate: Point'(1, 2).

A value is given by <> only where the component has a default expression, and so is each component of the ancestor part of an extension aggregate that names the ancestor by a subtype mark, (Shape with Radius => 2.0): Verada reads no component that was never given a value, where Ada leaves such a component default-initialized.

Example (Vada)

   P : Point := (X => 1);          --  no value for Y
   Q : Point := (1, 2, 3);         --  too many values
   R : Point := (X => 1, X => 2, Y => 3);

Example (Varc)

    let p: Point = (x: 1);              // no value for y
    let q: Point = (1, 2, 3);           // too many values
    let r: Point = (x: 1, x: 2, y: 3);

What to do (Vada)

Give each component one value, or use others => ... for the rest.

What to do (Varc)

Give each component one value, or use others: ... for the rest. Where the context does not determine the aggregate's type, qualify it: (1, 2) as Point.

Regression source and further reading

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

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