Writing out of range values

Official Description

6.6.5.2 For write, it is an error if the value possessed by the expression is not assignment-compatible with the buffer-variable.

Simplified Description

In other words, it is an error to write a value to a file, if the value is not assignment compatible with the file type's component type. Or to put it another way, it is an error to write a value to a file, if the value is not a valid value for that file. For example given:

   type
      positive = 0..maxint;
   var
      f : file of positive;

then

   write(f, -1);

is an error since -1 is not assignment compatible with 0..maxint.

Error Handling

This error is reported if range checking is enabled.