I'm not sure whether this is intentional, but I would prefer if this were allowed (or to know the rationale for disallowing it):
fooScript.sml:
open HolKernel bossLib;
val _ = new_theory"foo";
val _ = Datatype`foo = <| f : bool |>`;
val _ = export_theory();
barScript.sml:
open HolKernel bossLib fooTheory;
val _ = new_theory"bar";
val _ = Datatype`foo = <| f : bool |>`;
val _ = export_theory();
Exception raised at Datatype.Hol_datatype:
at Term.create_const:
not a type match
Exception- HOL_ERR {message = "at Term.create_const:\nnot a type match", origin_function = "Hol_datatype", origin_structure = "Datatype"} raised
Holmake: Failed script build for barScript - exited with code 1