Compatible types

Irie Pascal implements the type compatibility rules defined by Standard Pascal (ISO/IEC 7185), and adds one more rule to support variable length string types. The first four rules below are taken from ISO/IEC 7185 and the last rule is added to support variable length string types.

Types T1 and T2 shall be designated compatible if any of the following statements is true:

  1. T1 and T2 are the same type.
  2. T1 is a subrange of T2, or T2 is a subrange of T1, or both T1 and T2 are subranges of the same host type.
  3. T1 and T2 are set-types of compatible base-types, and either both T1 and T2 are designated packed or neither T1 nor T2 is designated packed.
  4. T1 and T2 are fixed-length-string-types with the same number of components.
  5. Either T1 is a variable-length-string-type and T2 is a variable-length-string-type, or T1 is a variable-length-string-type and T2 is a fixed-length-string-type, and the number of components in T2 is less than or equal to the maximum length of T1, or T1 is a variable-length-string-type and T2 is the char-type or T2 is a variable-length-string-type and T1 is a fixed-length-string-type, and the number of components in T1 is less than or equal to the maximum length of T2, or T2 is a variable-length-string-type and T1 is the char-type.