GNAT Studio ADA getting error "expected type "Standard.Integer"

In this Intro to Ada Course section about Arrays it shows that I can use a user defined type "Index" to index an array but when I try to index an array using a user defined type it says expected type "Standard.Integer". The reason why I'm asking this is because it explicitly states that you can use any discrete type to index an array.

procedure Cipher is
   type Byte is mod 2**8;
   type BufferArray is array ( 0 .. 15 ) of Byte;
   type Index is range 1 .. 16;
   Buffer: BufferArray := (0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
   buber: Byte := 255;
   --  Insert code here.
   for I in Index loop
      Put( Byte'Image(Buffer(I)) ); --error shows up here
   end loop;
end Cipher;

Is it just possible that its an issue with this specific version of GNAT?


  • You define the array as being indexed with your own defined type:

    type BufferArray is array (Index) of Byte;

    As a bonus, this definition removes automatically one bug in your code.