E00020

Example of illegal code:

```ada
   type Int_Access is access Integer;
   X : access Integer := new Integer'(12); --  error
   --  Attempt to borrow the result of an allocator; this should be a move

   function Allocate return Int_Access;
   Y : access Integer := Allocate; --  error
   --  Attempt to borrow the result of a call to an allocating function; this
   --  should be a move.

   function F (X : access Integer) return access Integer is
   begin
      return Allocate;  -- error
      --  Attempt to borrow the result of an allocator; this should be a move or
      --  F should return an operation on X (making F a traversal function).
   end F;
```

This error is issued on an operation that creates a borrower or an observer -
an assignment into an object of an anonymous access-to-object type, a
declaration of such an object, an actual parameter in a call when the associated
formal parameter has an anonymous access-to-object type, or a return statement
from a traversal function (i.e., a function whose return type is an anonymous
access-to-object type). It is issued when the source of the borrow or observe
- the assigned expression, the actual parameter, or the returned expression - is
not a part of a stand-alone object or a formal parameter.

If this message occurs on an object declaration or a call, a possible fix is to
store the value of the source of the borrow or observe in a local object of a
named access type, and possibly borrow it afterward if necessary:

```ada
   V : Int_Access := new Integer'(12);  -- Move the result of the allocator to V
   X : access Integer := V;  -- Borrow V if necessary
   W : Int_Access := Allocate;  -- Move the result of Allocate to W
   Y : access Integer := W;  -- Borrow W if necessary
```

Return values of traversal functions and assignments into objects of an
anonymous access type are called *reborrows* and are restricted even further.
The source of the borrow or observe should be a part of the target for an
assignment and a part of the first parameter for the result of a traversal
function. There is no systematic way to fix the problem in this case.

Remember: SPARK associates ownership-related semantics (move, observe, borrow)
during assignments based on the kind of Ada access type that is the assignment
target. For more information, consult Section 5.9 of the SPARK User’s Guide.
