I created new Mix.Task
in /lib/mix/tasks/start.ex for my project
defmodule Mix.Tasks.Start do
use Mix.Task
def run(_), do: IO.puts("Hello, World!")
end
Now, it could be run from console like this :mix start
But I'm getting Dialyzer error, that Callback info about the 'Elixir.Mix.Task' behaviour is not available
. What does it mean and how this could be fixed?
1.0) This task compiles the mix project, creates a PLT with dependencies if needed and runs dialyzer . Much of its behavior can be managed in configuration as described below.
Dialyzer is a static analysis tool for Erlang and other languages that compile to BEAM bytecode for the Erlang VM. It can analyze the BEAM files and provide warnings about problems in your code including type mismatches and other issues that are commonly detected by static language compilers.
Looks like I didn't have Persistent Lookup Table (PLT) options added for dialyzer. In my case for 'Elixir.Mix.Task' behavior to be available for dialyzer I had to update mix.exs file and define for which modules dialyzer should create PLT.
def project do
[
app: :some_app,
version: "0.1.0",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
deps: deps(),
# Added following line
dialyzer: [plt_add_apps: [:mix]]
]
end
dialyzer is added through dialyxir in same mix.exs file like this
defp deps do
[
{:dialyxir, "~> 0.5", only: [:dev], runtime: false}
]
end
mix do deps.get, deps.compile
And your dialyzer should stop complaining:mix dialyzer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With