As it says: JuliaFormatter can detect untyped fields; what I’m looking for is something to detect fields which are not completely nailed down.
1 Like
If you know the types for the fields you want to use (i.e. the struct is not parametric) then
struct A
x::Int
end
isconcretetype.(fieldtypes(A)) # (true,)
struct B
x
end
isconcretetype.(fieldtypes(B)) # (false,)
But if you got a parametric type then I think you can’t know it from the definition
struct C{T}
x::T
end
isconcretetype.(fieldtypes(C)) # (false,)
isconcretetype.(fieldtypes(C{Any})) # (false,)
isconcretetype.(fieldtypes(C{Int})) # (true,)
1 Like
Thank you, this is useful.
However, my concern is primarily with an inspection of the source code. I have many parametric types, and it would be good to check that the struct fields use these parametric types fully qualified.