{: test that assigning to a set outside its bounds causes a fatal error
   test bounds error at upper set boundary for 
              constlist with range - constlist with range 
}

{ this is a generic test, many versions of this test will be built with
  cpp -D ARG1=ARG -D ARG2=(ARG+ADJ)
  for all combinatiopns of ARG & ADJ

ARG   -17 -16 -15 -1 0 2 15 16 17
ADJ   1 7 8
}

{$d+}
program d287( output );
const
   top = 40;
   lo  = -30;
   hi  = ARG1;
   eltest = ARG2;
var
   i, j, k : integer;
   s0      : set of lo..hi;    {dst}
   s1, s2  : set of -top..top; {src}

begin {d287}
   j := eltest;
   i := lo; k := hi; {min,max element of s0}
   s1 := [k..j+1, i..i+4, hi-4, hi];    {unused}
   s2 := [k..j+1, i+4, hi-4];
   writeln( 'INFO: s0 is [', lo:1, '..', hi:1, ']' );{}
   s0 :=  [i,hi..eltest+1] - [hi..eltest+1, j] ;       {OK}
   s2 := [lo+4, k-4, k+1..j-1,j+1]; 
   s0 :=  [i,hi..eltest+1] - [hi+1..eltest-1,eltest+1, j+1] ;   {!!! assignment outside bounds}
   writeln('failed to detect set assign error');
end. { d287 }
