{: test succ range error causes a fatal error }

{d+}
program d1016( output );

type
   colour = ( black, brown, red, orange, yellow, green, blue, violet, grey, white);
var
   k : integer;
   c : colour;

function side: integer;
begin
   side := k;
   k := k+1;
end;
begin {d1016}

   k := 2;
   if succ( orange, -side ) <> brown then
      writeln( 'succ error 1' );
   if k <> 3 then
      writeln( 'succ error 2' );
   k := 3;
   if succ( red, side ) <> green then
      writeln( 'succ error 3' );
   if k <> 4 then
      writeln( 'succ error 4' );
   if succ(violet, 2) <> white then
      writeln( 'succ error 5' );

   c := grey;
   if (ord(succ( c, 2 )) = 0) or true then
      writeln( 'fails: succ range error is not detected' );
end. { d1016 }

