HP Pascal/iX Reference Manual (31502-90022)

3- 26
compatible. In the following example, types T1 and T2 are not
compatible. Variables v3 and v4 are also not compatible.
PROGRAM t(input,output);
TYPE
T1 = record
a: integer;
b: char;
end;
T2 = record
c: integer;
d: char;
end;
VAR
v1: T1;
v2: T2;
v3: ^T1;
v4: ^T2;
BEGIN
v1:= v2; { This generates a compile-time error }
v3:= v4; { This generates a compile-time error }
END.
Assignment Compatibility
A value of type T2 may only be assigned to a variable or function result
of type T1 if T2 is
assignment compatible
with T1. For T2 to be
assignment compatible
with T1, any of the following conditions must be
true:
* T1 and T2 are type compatible types that are neither files nor
structures that contain files.
* T1 is real or longreal, and T2 is integer or an integer subrange.
The compiler converts T2 to real or longreal prior to assignment.
* T1 is longreal and T2 is real. The compiler converts T2 to
longreal prior to assignment.
* T1 is real and T2 is longreal. The compiler rounds T2 to the
precision of T1 prior to assignment.
Furthermore, a
run-time
or
compile-time
error occurs if the following
restrictions are not observed:
* If T1 and T2 are type compatible ordinal types, the value of type
T2 must be in the closed interval specified by T1.
* If T1 and T2 are type compatible set types, all the members of the
value of type T2 must be in the closed interval specified by the
base type of T1.
* A special set of restrictions applies to assignment of string
literals or variables of type string, PAC, or char.
NOTE The pointer constant NIL is both type compatible and assignment
compatible with any pointer type. Likewise, the empty set ( [ ] )
is both type compatible and assignment compatible with any set
type.