{: test pred range error causes a fatal error }

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

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

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

