
{: test that using a with statement with a record variant with an invalid tag
   value causes a fatal error }

{$d+,v+}
program d116( output );

var
   myRec :  record
               case t: boolean of
                 true  : ( i: integer;
                           c: char;
                          );
                 false : ( r: record x: real; end);
               end; {record }
begin { d116 }


   myRec.t := true;  { access i varaint }

   myRec.i := -1;
   write( 'integer is ', myRec.i );

   myRec.t := false;  { access x varaint }
   with myRec.r do begin
      x := 99.9;
      write( ', x is ', x:1:2 );
   end;

   myRec.t := true;

   with myRec.r do begin  { !!! incorrect tag/variant combo }
      x := 100.6;
      writeln( ', x is ', x:1:1 );
   end;

   writeln( 'use of invalid tag not detected' );
end. { d116 }

