Is there a tool to detect non-concrete struct fields in type definitions?

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

isconcretetype.(fieldtypes(A)) # (true,)

struct B

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}

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.