DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B0502: Verada's extension of Ada without pragma Extensions_Allowed (On)

Catalog status: active. Default severity: error. Stable name: extension-without-pragma. Family: Syntax and source text.

Verada extends Ada's iterator with two clauses: while C, which ends the iteration at the first element (that passed any when filter) for which C is false, and sources walked in step, for X of A, Y of B, which ends with the shorter. Ada has no such clause, so Vada takes it only where the file asks for extensions with the recognized Extensions_Allowed pragma. This records the source's use of an extension; it does not establish that GNAT accepts Verada's additional clauses. Varc's take_while(x => p) and for x in a, y in b are Varc's own syntax and need no pragma.

Example (Vada)

procedure Main is
   type Arr is array (Positive range <>) of Integer;
   A : constant Arr := (3, 1, 0, 4);
   Prefix : constant Integer := [for X of A while X > 0 => X]'Reduce ("+", 0);
begin
   null;
end Main;

What to do (Vada)

Add pragma Extensions_Allowed (On); at the head of the file, or write the loop with an exit when instead. See the Vada extension boundary before using the source with another Ada implementation.

Regression source and further reading

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

See syntax and source text, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.