Consider the following example:
p.ads:
package P is
type T is tagged private;
private
type S (B : Boolean) is tagged null record;
type T is new S (B => True) with null record;
end P;
q.ads:
with P;
package Q is
type R (B : Boolean) is record
case B is
when True =>
X : P.T;
when False =>
null;
end case;
end record;
end Q;
Compiling q.ads yields the following error message:
q.ads:4:10: error: expected private type "T" defined at p.ads:2
q.ads:4:10: error: found private type "T" defined at p.ads:2
The error is fixed if we either make T not private, S and T not tagged, or R not discriminated. Also simply removing the tagged keyword from the initial declaration of T. In any event, the error message seems absurd. What is going on here?