Integer types |
SHORTINT, INTEGER, LONGINT |

Real types |
REAL, LONGREAL |

Numeric types |
integer types, real types |

- Same types
- Equal types
- Type inclusion
- Type extension (base type)
- Assignment compatible
- Array compatible
- Expression compatible
- Matching formal parameter lists

Two variables a and b with types Ta and Tb are of the *same* type if

- Ta and Tb are both denoted by the same type identifier, or
- Ta is declared to equal Tb in a type declaration of the form Ta = Tb, or
- a and b appear in the same identifier list in a variable, record field, or formal parameter declaration and are not open arrays.

Two types Ta and Tb are *equal* if

- Ta and Tb are the
*same*type, or - Ta and Tb are open array types with
*equal*element types, or - Ta and Tb are procedure types whose formal parameter lists
*match*.

Numeric types *include* (the values of) smaller numeric types according to the following hierarchy LONGREAL REAL LONGINT INTEGER SHORTINT

Given a type declaration Tb` = RECORD (`Ta`)... END`, Tb is a *direct extension* of Ta, and Ta is a *direct base type* of Tb. A type Tb is an *extension* of a type Ta (Ta is a *base type* of Tb) if

- Ta and Tb are the
*same*types, or - Tb is a
*direct extension*of an*extension*of Ta

If Pa` = POINTER TO `Ta and Pb` = POINTER TO `Tb, Pb is an *extension* of Pa (Pa is a *base type* of Pb) if Tb is an *extension* of Ta.

An expression e of type Te is *assignment compatible* with a variable v of type Tv if one of the following conditions hold:

- Te and Tv are the
*same*type; - Te and Tv are numeric types and Tv
*includes*Te; - Te and Tv are record types and Te is an
*extension*of Tv and the dynamic type of v is Tv ; - Te and Tv are pointer types and Te is an
*extension*of Tv; - Tv is a pointer or a procedure type and e is NIL;
- Tv is ARRAY n OF CHAR, e is a string constant with m characters, and m < n;
- Tv is a procedure type and e is the name of a procedure whose formal parameters
*match*those of Tv.

An actual parameter a of type Ta is *array compatible* with a formal parameter f of type Tf if

- Tf and Ta are the
*same*type, or - Tf is an open array, Ta is any array, and their element types are
*array compatible*, or - Tf is ARRAY OF CHAR and a is a string.

For a given operator, the types of its operands are *expression compatible* if they conform to the following table (which shows also the result type of the expression). Character arrays to be compared must contain 0X as a terminator. Type T1 must be an extension of type T0:

operator | first operand | second operand | result type |

+ - * |
numeric | numeric | smallest numeric type including both operands |

/ |
numeric | numeric | smallest real type including both operands |

+ - * / |
SET | SET | SET |

DIV MOD | integer | integer | smallest integer type including both operands |

OR & ~ |
BOOLEAN | BOOLEAN | BOOLEAN |

= # < <= > >= |
numeric | numeric | BOOLEAN |

CHAR | CHAR | BOOLEAN | |

character array, string | character array, string | BOOLEAN | |

= # |
BOOLEAN | BOOLEAN | BOOLEAN |

SET | SET | BOOLEAN | |

NIL, POINTER TO T0 or T1 | NIL, POINTER TO T0 or T1 | BOOLEAN | |

procedure type T, NIL | procedure type T, NIL | BOOLEAN | |

IN | integer | SET | BOOLEAN |

IS | pointer | pointer | BOOLEAN |

record | record | BOOLEAN |

Two formal parameter lists *match* if

- they have the same number of parameters, and
- they have either the
*same*function result type or none, and - parameters at corresponding positions have
*equal*types, and - parameters at corresponding positions are both either value or variable parameters.