Code: Select all
MODULE M0;
IMPORT Main, Out;
TYPE
Mp* = POINTER TO Mdesc;
M0p* = POINTER TO M0desc;
Mdesc* = RECORD END;
M0desc* = RECORD (Mdesc) END;
M1p* = POINTER TO M1desc;
M1desc* = RECORD (M0desc) END;
VAR
mp: Mp;
m0p: M0p;
m1p: M1p;
BEGIN
NEW(m1p);
mp := m1p;
ASSERT(mp IS M0p, 200);
Out.String("assert ok"); Out.Ln;
m0p := mp(M0p);
Out.String("type guard ok"); Out.Ln
END M0.
Now consider this modified second test case, moving part of the type defs to another module:
Code: Select all
MODULE T2;
TYPE
Mp* = POINTER TO Mdesc;
M0p* = POINTER TO M0desc;
Mdesc* = RECORD END;
M0desc* = RECORD (Mdesc) END;
END T2.
MODULE M1;
IMPORT T2, Main, Out;
TYPE
M1p* = POINTER TO M1desc;
M1desc* = RECORD (T2.M0desc) END;
VAR
mp: T2.Mp;
m0p: T2.M0p;
m1p: M1p;
BEGIN
NEW(m1p);
mp := m1p;
ASSERT(mp IS T2.M0p, 200);
Out.String("assert ok"); Out.Ln;
m0p := mp(T2.M0p);
Out.String("type guard ok"); Out.Ln
END M1.
What do I miss?
(Latest Astrobe for RP2350, command line compiler and linker.)