I am using the ElixirLS extension in Visual Studio Code.
The Dialyzer is very helpful in finding errors in my code, however it is extremely hard to parse its error messages.
For example, I was trying to generate a random date in the future doing:
NaiveDateTime.add(NaiveDateTime.utc_now(), Enum.random(4..10), :day)
The problem with the above code is :day
is not a valid parameter to the NaiveDateTime.add
method.
Here is what I get from ElixirLS:
The call 'Elixir.NaiveDateTime':add(#{'__struct__':='Elixir.NaiveDateTime', 'calendar':=atom(), 'day':=pos_integer(), 'hour':=non_neg_integer(), 'microsecond':={char(),0 | 1 | 2 | 3 | 4 | 5 | 6}, 'minute':=non_neg_integer(), 'month':=pos_integer(), 'second':=non_neg_integer(), 'year':=integer()},any(),'day') will never return since the success typing is (#{'calendar':=atom(), 'day':=_, 'hour':=_, 'microsecond':={_,_}, 'minute':=_, 'month':=_, 'second':=_, 'year':=_, _=>_},integer(),'microsecond' | 'millisecond' | 'nanosecond' | 'native' | 'second' | pos_integer()) -> #{'__struct__':='Elixir.NaiveDateTime', 'calendar':=atom(), 'day':=_, 'hour':=_, 'microsecond':={_,_}, 'minute':=_, 'month':=_, 'second':=_, 'year':=_} and the contract is ('Elixir.Calendar':naive_datetime(),integer(),'Elixir.System':time_unit()) -> t() ElixirLS Dialyzer
Is there a way to make this easier to read so I can quickly I identify that :day
didn’t match 'Elixir.System':time_unit()
?