DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B1009: attribute not allowed here

Catalog status: active. Default severity: error. Stable name: misplaced-attribute. Family: Names and declarations.

Some attributes only make sense in particular places: X'Old and F'Result in a postcondition ('Result only for functions), X'Range where a range is expected, and @ (the target name) in the value of an assignment.

Example (Vada)

   function Twice (N : Integer) return Integer
     with Pre => N'Old < 100;    --  'Old belongs in Post

Example (Varc)

    fn twice(n: Integer) -> Integer
        requires old(n) < 100    // `old` belongs in `ensures`
    = 2 * n;

What to do (Vada)

Move the attribute to where it is defined, or use 'First and 'Last instead of 'Range in an expression.

What to do (Varc)

Move old(...) or result to an ensures clause, or use ::First and ::Last instead of ::Range in an expression.

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.