Ah, sorry, your constructor for the parametric type needs to be TDatumVal{T}() where T = ....
Here’s a more similar example:
mutable struct Foo{T}
x::Union{Nothing, T}
Foo{T}() where T = new(nothing)
end
Foo() = Foo{Bar}()
mutable struct Bar
x::Foo{Bar}
end
f = Foo()
f.x = Bar(f)
I’m not sure how you’re constructing your type, but you’ll have to make sure you either explicitly create it with TDatumVal{TDatum}() or create a new method (like in my example above) that fills in the type parameter for you.