I’m checking on how to make my Elixir code more refactorable and for that reason testing Gradualizer with @OvermindDL1’s gradualixir package.
Suppose I have the following module type “Stuff”:
@type t() :: %Types.Stuff{foo: String.t()}
And the following function with a signature:
@spec check_gradualizer() :: Types.Stuff.t()
def check_gradualizer() do
%TimeclockParser.Types.Stuff{
foo: 1
}
end
Gradualizer will report, correctly, that I tried to make foo a number, while it is actually a String.t
.
But if I simply assign the struct creation to a variable and return that:
@spec check_gradualizer() :: Types.Stuff.t()
def check_gradualizer() do
entry = %TimeclockParser.Types.Stuff{
foo: 1
}
entry
end
I get no reports whatsoever. Is this expected? A usage error? Or simply a bug?