There appears to be a bug with datatype replication when the to-be-replicated type is brought into scope by an open.
[fluet@shadow tmp]$ poly Poly/ML 5.3 Release candidate 1
structure S1 = struct open Date datatype t = datatype weekday end;
Exception- InternalError: codeVal - Formal raised while compiling
Exception- InternalError: codeVal - Formal raised while compiling
Also, the Definition allows binding non-datatypes with datatype replication, so the following should be accepted:
[fluet@shadow tmp]$ poly
Poly/ML 5.3 Release candidate 1
structure S2 = struct datatype t = datatype char end;
Error-char is not a datatype Found near datatype t = datatype char Static Errors