{: test succ range error causes a fatal error }

{d+}
program d1017( 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 {d1017}

   k := 2;
   if succ( blue, -side ) <> yellow then
      writeln( 'succ error 1' );
   if k <> 3 then
      writeln( 'succ error 2' );
   k := 2;
   if succ( blue, side ) <> grey then
      writeln( 'succ error 3' );
   if k <> 3 then
      writeln( 'succ error 4' );
   if succ(red, -2) <> black then
      writeln( 'succ error 5' );

   c := red;
   if (ord(succ( c, -3 )) = 0) or true then
      writeln( 'fails: succ range error is not detected' );
end. { d1017 }

