Karl Landström 2017-10-11 (edited 2018-01-28)
The type compatibility rules in the Oberon report (2016) are not completely specified. To fill in the missing pieces, appendix A from The Programming Language Oberon-2 (1993) by Hanspeter Mössenböck and Niklaus Wirth is used here as a template, with adjustments for the 2016 edition of Oberon.
Note that Oberon uses non-strict name equivalence. This means that for a type identifier Ta, the type declarations Tb = Ta and Tc = Ta make Tb and Tc equivalent.
Two variables a and b with types Ta and Tb are of the same type if
Two types Ta and Tb are equal if
An expression e of type Te is assignment compatible with a variable v of type Tv if one of the following conditions hold:
An actual parameter a of type Ta is array compatible with a formal parameter f of type Tf if
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 that are 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 |
---|---|---|---|
+ − * | INTEGER, BYTE | INTEGER, BYTE | INTEGER |
+ − * / | REAL | REAL | REAL |
SET | SET | SET | |
DIV MOD | INTEGER, BYTE | INTEGER, BYTE | INTEGER |
OR & ~ | BOOLEAN | BOOLEAN | BOOLEAN |
= # < <= > >= | CHAR, one-char string | CHAR, one-char string | BOOLEAN |
INTEGER, BYTE | INTEGER, BYTE | BOOLEAN | |
REAL | REAL | BOOLEAN | |
character array, string | character array, string | BOOLEAN | |
= # | BOOLEAN | BOOLEAN | BOOLEAN |
SET | SET | BOOLEAN | |
pointer type T0 or T1, or NIL | pointer type T0 or T1, or NIL | BOOLEAN | |
procedure type T or NIL | procedure type T or NIL | BOOLEAN | |
IN | INTEGER, BYTE | SET | BOOLEAN |
IS | type T0 | type T1 | BOOLEAN |
Two formal parameter lists match if