jeremyjh / dialyxir Goto Github PK
View Code? Open in Web Editor NEWMix tasks to simplify use of Dialyzer in Elixir projects.
License: Apache License 2.0
Mix tasks to simplify use of Dialyzer in Elixir projects.
License: Apache License 2.0
When using a dialyzer.ignore-warnings-like file, but it is still empty, dialyxer crashes on run with:
** (ArgumentError) argument error
(stdlib) :binary.compile_pattern([""])
lib/dialyxir/project.ex:55: Dialyxir.Project.filter_warnings/2
lib/mix/tasks/dialyzer.ex:155: Mix.Tasks.Dialyzer.dialyze/3
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:370: Code.require_file/2
Hi!
First things first, thanks for keeping this project up and alive :)
I saw some superfluous errors when using Dialyxir with Elixir 0.14.
For every module declared, there is an error line like this:
rockside.ex:1: Type specification 'Elixir.Rockside':'__info__'(atom()) -> term() is a supertype of the success typing: 'Elixir.Rockside':'__info__'('attributes' | 'compile' | 'exports' | 'functions' | 'imports' | 'macros' | 'module' | 'native_addresses') -> atom() | [{atom(),_} | {atom(),byte(),integer()}]
In this example the offending line is just defmodule Rockside do
and this behavior repeats for every module compiled in the project.
Do you have any idea if this is some known issue with types and specs in newest Elixir, or just Dialyxir not catching up things in 0.14.x line?
I also hope to find some time to do regressions of this error in the upcoming Elixir releases - assuming your plan would be to catch up the current stable Elixir codebase.
Best,
I'm getting:
dialyzer: No such file, directory or application "(redacted)/_build/dev/dialyxir_erlang-19.1_elixir-1.3.4_deps-dev.plt"
I would usually do mix dialyzer.plt but it does not exist anymore as far as I can tell.
== Compilation error on file lib/dialyzer.plt.ex ==
could not compile dependency dialyxir, mix compile failed. In case you want to recompile this dependency, please run: mix deps.compile dialyxir
** (SyntaxError) /Users/emerrit/workspace/vaquero/deps/dialyxir/lib/dialyzer.plt.ex:95: unexpected comma. Parentheses are required to solve ambiguity in nested calls. Syntax error before: ','
src/elixir_parser.yrl:621: :elixir_parser.throw/3
src/elixir_parser.yrl:377: :elixir_parser.yeccpars2_282/7
/usr/local/Cellar/erlang-r16/R16B/lib/erlang/lib/parsetools-2.0.9/include/yeccpre.hrl:56: :elixir_parser.yeccpars0/5
src/elixir_translator.erl:16: :elixir_translator.forms/4
src/elixir_translator.erl:28: :elixir_translator.forms!/4
src/elixir_compiler.erl:24: :elixir_compiler.string/2
src/elixir_compiler.erl:48: :elixir_compiler.file_to_path/2
/private/tmp/elixir-AtVN/lib/elixir/lib/kernel/parallel_compiler.ex:68: Kernel.ParallelCompiler."-spawn_compilers/7-fun-0-"/3
Since v0.11.2 (2013-11-14) the beam files are located at _build
.
Why don't you publish to hex.pm, so one could specify dialyxir
as a dev-dependency?
Hi there,
I'm trying to use dialyxir with a new project. I'm using asdf for erlang and elixir version management. When I run mix dialyzer --plt
I get the following error:
1& [john:~/Public/project] 2m43s 1 % mix dialyzer --plt
Checking PLT...
[:asn1, :bunt, :certifi, :compiler, :credo, :crypto, :dialyxir, :dialyzer,
:elixir, :hackney, :hipe, :httpoison, :idna, :inets, :kernel, :logger,
:metrics, :mimerl, :mix, :poison, :public_key, :ssl, :ssl_verify_fun, :stdlib,
:wx]
Finding suitable PLTs
Looking up modules in dialyxir_erlang-19.0_elixir-1.4.1_deps-dev.plt
Looking up modules in dialyxir_erlang-19.0_elixir-1.4.1.plt
Looking up modules in dialyxir_erlang-19.0.plt
Finding applications for dialyxir_erlang-19.0.plt
Finding modules for dialyxir_erlang-19.0.plt
Creating dialyxir_erlang-19.0.plt
:dialyzer.run error: Could not get abstract code for file: /home/john/.asdf/installs/erlang/19.0/lib/erlang/lib/erts-8.0/ebin/erlang.beam (please recompile it with +debug_info)
Looking up modules in dialyxir_erlang-19.0.plt
** (Mix) Could not open /home/john/.asdf/installs/elixir/1.4.1/.mix/dialyxir_erlang-19.0.plt: no such file or directory
I don't really understand what this error is, and I'm not sure whether it's an issue with dialyxir or my erlang install?
Hi,
interesting tool, but I wanted to read the paper linked and the link seems down : http://user.it.uu.se/~kostis/Papers/succ_types.pdf
thanks for your answer
Given:
defmodule PotentialBugReport do
defp double(x), do: {:ok, 2 * x}
defp tripple(x), do: {:ok, 3 * x}
def foobar(x) do
with {:ok, two_times} <- double(x),
{:ok, three_times} <- tripple(x) do
IO.puts "2x = #{inspect two_times} and 3x = #{inspect three_times}"
end
end
end
Dialyxir outputs:
potential_bug_report.ex:6: The variable _@6 can never match since previous clauses completely covered the type {'ok',number()}
potential_bug_report.ex:7: The variable _@5 can never match since previous clauses completely covered the type {'ok',number()}
Am I doing something wrong?
In my umbrella, I have two applications that define the same module. The module formats my filesystem - so there is a 'real' version for nerves with env 'prod' and a dummy version for everything else. Dialyzer throws me this error:
~/P/temp-relay ❯❯❯ MIX_ENV=dev mix dialyzer
==> storage
Compiling 1 file (.ex)
warning: redefining module Storage (current version loaded from /Users/jeff.utter/Projects/temp-relay/_build/dev/lib/dummy_nerves/ebin/Elixir.Storage.beam)
lib/storage.ex:1
Generated storage app
Checking PLT...
[:asn1, :certifi, :combine, :compiler, :cowboy, :cowlib, :crypto, :eex, :elixir,
:exjsx, :gettext, :gproc, :hackney, :idna, :jsx, :kernel, :logger, :metrics,
:mime, :mimerl, :msgpax, :nerves_firmware, :nerves_firmware_http, :nerves_ntp,
:phoenix, :phoenix_html, :phoenix_pubsub, :plug, :poison, :public_key, :ranch,
:runtime_tools, :ssl, :ssl_verify_fun, :stdlib, :thermostat, :timex, :tzdata,
:ui]
PLT is up to date!
Starting Dialyzer
dialyzer --no_check_plt --plt /Users/jeff.utter/Projects/temp-relay/_build/dev/dialyxir_erlang-19.1_elixir-1.3.4_deps-dev.plt /Users/jeff.utter/Projects/temp-relay/_build/rpi/dev/lib/fw/ebin /Users/jeff.utter/Projects/temp-relay/_build/dev/lib/ui/ebin /Users/jeff.utter/Projects/temp-relay/_build/dev/lib/thermostat/ebin /Users/jeff.utter/Projects/temp-relay/_build/dev/lib/dummy_nerves/ebin /Users/jeff.utter/Projects/temp-relay/_build/dev/lib/storage/ebin
Compiling some key modules to native code... done in 0m0.23s
Proceeding with analysis...
dialyzer: Analysis failed with error:
Duplicate modules: [["/Users/jeff.utter/Projects/temp-relay/_build/dev/lib/dummy_nerves/ebin/Elixir.Storage.beam",
"/Users/jeff.utter/Projects/temp-relay/_build/dev/lib/storage/ebin/Elixir.Storage.beam"]]
Last messages in the log cache:
Reading files and computing callgraph...
Is there a way to make dialyzer ignore the storage
app?
I'm using Elixir 1.0.5. After upgrading from OTP 17.5 to 18.0 the core build fails.
fbreunig@Cod:~/Workspace/dialyxir (master) 🍔 mix dialyzer.plt
Starting PLT Core Build ... this will take awhile
dialyzer --output_plt /Users/fbreunig/.dialyxir_core_18_1.0.5.plt --build_plt --apps erts kernel stdlib crypto public_key -r /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../eex/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../iex/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin
Compiling some key modules to native code... done in 0m0.28s
Creating PLT /Users/fbreunig/.dialyxir_core_18_1.0.5.plt ...
dialyzer: Analysis failed with error:
Could not scan the following file(s):
Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.NoTaskError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.NoProjectError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.InvalidTaskError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Error.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.ElixirVersionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Dep.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Config.LoadError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../iex/ebin/Elixir.IEx.State.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.TimeoutError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.TestCase.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.Test.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.DocTest.Error.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.AssertionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Version.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Version.Requirement.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Version.InvalidVersionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.UnicodeConversionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Version.InvalidRequirementError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.UndefinedFunctionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.URI.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.TryClauseError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.TokenMissingError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Task.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.SystemLimitError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.System.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.SyntaxError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Supervisor.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Stream.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.RuntimeError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Regex.CompileError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Regex.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Range.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Protocol.UndefinedError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.MatchError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Macro.Env.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.KeyError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Inspect.Opts.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.IO.StreamError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.IO.Stream.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.HashSet.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.HashDict.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.FunctionClauseError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.File.Error.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.GenEvent.Stream.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.File.CopyError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.File.Stream.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.ErlangError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.File.Stat.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Exception.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Enum.OutOfBoundsError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Enum.EmptyError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.CondClauseError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.CompileError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.Code.LoadError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.CaseClauseError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.BadStructError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.BadMapError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.BadFunctionError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.BadArityError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.ArithmeticError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin/Elixir.ArgumentError.beam Could not get core Erlang code for: /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../eex/ebin/Elixir.EEx.SyntaxError.beam
Last messages in the log cache:
Reading files and computing callgraph...
** (FunctionClauseError) no function clause matching in Keyword.get/3
(elixir) lib/keyword.ex:118: Keyword.get(:no_such_file, :files, nil)
lib/mix/tasks/dialyzer.plt.ex:132: Mix.Tasks.Dialyzer.Plt.core_plt_contains?/2
lib/mix/tasks/dialyzer.plt.ex:123: anonymous fn/1 in Mix.Tasks.Dialyzer.Plt.missing_apps/0
(elixir) lib/enum.ex:662: anonymous fn/3 in Enum.filter/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:662: Enum.filter/2
lib/mix/tasks/dialyzer.plt.ex:106: Mix.Tasks.Dialyzer.Plt.need_add?/0
lib/mix/tasks/dialyzer.plt.ex:57: Mix.Tasks.Dialyzer.Plt.run/1
Using the defexception
macro gives us an overridable exception/1
function whose typespec is:
@spec exception(Keyword.t) :: Exception.t
However, treating the argument as a Keyword list results in a type error (even though the code compiles and works):
defmodule MyAppError do
defexception [:message]
def exception(args) when is_list(args) do
message = Keyword.get(args, :message)
%MyAppError{message: message}
end
end
my_app.ex:2: Type specification 'Elixir.MyAppError':exception('Elixir.Keyword':t()) -> 'Elixir.Exception':t()
; ('Elixir.String':t()) -> 'Elixir.Exception':t() is a supertype of the success typing:
'Elixir.MyAppError':exception([{atom(),_}]) -> #{'__exception__':='true', '__struct__':='Elixir.MyAppError', 'message':=_}
If I first pass args
to Keyword.new/1
or access it with List.keyfind/4
the error goes away:
def exception(args) when is_list(args) do
message = args |> Keyword.new |> Keyword.get(:message)
{:message, message} = List.keyfind(args, :message, 0)
%MyAppError{message: message}
end
Any idea what's going on here?
The 0.4 release (in progress in develop
branch) is intended to address many deep and longstanding problems in dialyxir and will include significant changes to defaults which may well be "breaking" for some projects until configuration is removed or updated.
The general principal behind the changes is to provide:
* simplest possible operation - less user configuration for expected usage
* defaults appropriate for a new user of dialyzer
* a smooth experience for projects built on popular frameworks such as Phoenix out-of-the-box
* correct, complete results by default
See this forum post for more background.
If you wish to contribute work on one of the unchecked items please create a new issue for it to claim it, referencing this issue. If you have other ideas you can make suggestions in this issue or open a new issue referencing this issue if you think it will need a lot of discussion.
dialyze
PLT file management, e.g. erlang/elixir core file copied into _build, app dependencies added only to this project local filedialyze
plt update functionality (add/remove individual modules from dependencies)Hi there,
I'm trying to run mix dialyzer.plt
with dialyxir 0.3.3 on OSX El Capitan. Elixir and OTP Versions:
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Elixir 1.2.2
Mix 1.2.2
$ mix dialyzer.plt
Starting PLT Core Build ... this will take awhile
dialyzer --output_plt /Users/CGR/.dialyxir_core_18_1.2.2.plt --build_plt --apps erts kernel stdlib crypto public_key -r /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../eex/ebin /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../elixir/ebin /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../ex_unit/ebin /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../iex/ebin /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../logger/ebin /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../mix/ebin
dialyzer: Could not get abstract code for file: /usr/local/Cellar/elixir/1.2.2/bin/../lib/elixir/../elixir/ebin/Elixir.String.Graphemes.beam (please recompile it with +debug_info)
** (FunctionClauseError) no function clause matching in Keyword.get/3
(elixir) lib/keyword.ex:150: Keyword.get(:no_such_file, :files, nil)
lib/mix/tasks/dialyzer.plt.ex:142: Mix.Tasks.Dialyzer.Plt.core_plt_contains?/2
lib/mix/tasks/dialyzer.plt.ex:133: anonymous fn/1 in Mix.Tasks.Dialyzer.Plt.missing_apps/0
(elixir) lib/enum.ex:738: anonymous fn/3 in Enum.filter/2
(elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:738: Enum.filter/2
lib/mix/tasks/dialyzer.plt.ex:116: Mix.Tasks.Dialyzer.Plt.need_add?/0
lib/mix/tasks/dialyzer.plt.ex:57: Mix.Tasks.Dialyzer.Plt.run/1
Could this be a problem with the brew package I have used to install elixir? I have tried to run mix dialyzer.plt
in this repo: https://github.com/fourcube/metrics/tree/dialyxir_test
the new plt_add_deps works generally, but seems to skip some apps randomly. I have an app that has cowboy and dialyxir as dependencies, cowboy has the dependency of ranch, but ranch isn't part of the path and so it blows up if that is in the plt app list
I'm having the following issue with the latest version and I can't find a good solution anywhere. I am trying to run dialyxir on https://github.com/KallDrexx/elixir-media-libs/tree/c794f29cf3a4f009535936b5ed98223bad9c072a
D:\Code\My Projects\elixir-media-libs
λ mix dialyzer
Checking PLT...
[:amf0, :compiler, :earmark, :elixir, :ex_doc, :gen_rtmp_server, :kernel,
:logger, :ranch, :rtmp, :stdlib, :uuid]
Finding suitable PLTs
Looking up modules in dialyxir_erlang-18.2.1_elixir-1.4.0_deps-umbrella.plt
Finding applications for dialyxir_erlang-18.2.1_elixir-1.4.0_deps-umbrella.plt
Finding modules for dialyxir_erlang-18.2.1_elixir-1.4.0_deps-umbrella.plt
Checking 376 modules in dialyxir_erlang-18.2.1_elixir-1.4.0_deps-umbrella.plt
Adding 213 modules to dialyxir_erlang-18.2.1_elixir-1.4.0_deps-umbrella.plt
21:04:01.299 [error] Process #PID<0.19137.0> raised an exception
** (FunctionClauseError) no function clause matching in :cerl.map_arg/1
(compiler) cerl.erl:1608: :cerl.map_arg({:c_literal, [], #MapSet<["address", "article", "aside", "blockquote", "canvas", "dd", "div", "dl", "fieldset", "figcaption", "h1", "h2", "h3", "h4", "h5",
"h6", "header", "hgroup", "li", "main", "nav", "noscript", "ol", "output", "p", "pre", "section", "table", "tfoot", "ul", "video"]>})
c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_prettypr.erl:614: :cerl_prettypr.lay_map/2
c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_prettypr.erl:413: :cerl_prettypr.lay_ann/2
c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_prettypr.erl:273: :cerl_prettypr.format/2
dialyzer_dataflow.erl:3350: :dialyzer_dataflow.format_args_1/3
dialyzer_dataflow.erl:3343: :dialyzer_dataflow.format_args/3
dialyzer_dataflow.erl:603: :dialyzer_dataflow.get_apply_fail_msg/10
dialyzer_dataflow.erl:544: :dialyzer_dataflow.handle_apply_or_call/9
21:04:01.346 [error] Process #PID<0.19128.0> raised an exception
** (ArgumentError) argument error
(stdlib) :ets.lookup(4505653, {:in, {Inspect.BitString, :inspect_bitstring, 2}})
(stdlib) digraph.erl:225: :digraph.in_neighbours/2
dialyzer_callgraph.erl:571: :dialyzer_callgraph.digraph_in_neighbours/2
dialyzer_dataflow.erl:3125: :dialyzer_dataflow.state__add_work_from_fun/2
dialyzer_dataflow.erl:232: :dialyzer_dataflow.analyze_loop/1
dialyzer_dataflow.erl:174: :dialyzer_dataflow.analyze_module/6
dialyzer_dataflow.erl:159: :dialyzer_dataflow.get_fun_types/5
dialyzer_succ_typings.erl:264: :dialyzer_succ_typings.refine_one_module/2
** (throw) {:dialyzer_error, 'Analysis failed with error:\n{function_clause,\n [{cerl,map_arg,\n [{c_literal,[],\n \#{\'__struct__\' => \'Elixir.MapSet\',\n map
=> \#{<<"address">> => true,\n <<"article">> => true,\n <<"aside">> => true,\n <<"blockquote">> => true,\n <<"canvas">> => true,\n
<<"dd">> => true,\n <<"div">> => true,\n <<"dl">> => true,\n <<"fieldset">> => true,\n <<"figcaption">> => true,\n
<<"h1">> => true,\n <<"h2">> => true,\n <<"h3">> => true,\n <<"h4">> => true,\n <<"h5">> => true,\n
<<"h6">> => true,\n <<"header">> => true,\n <<"hgroup">> => true,\n <<"li">> => true,\n <<"main">> => true,\n <<"n
av">> => true,\n <<"noscript">> => true,\n <<"ol">> => true,\n <<"output">> => true,\n <<"p">> => true,\n <<"pre">>
=> true,\n <<"section">> => true,\n <<"table">> => true,\n <<"tfoot">> => true,\n <<"ul">> => true,\n <<"video">>
=> true}}}],\n [{file,"cerl.erl"},{line,1608}]},\n {cerl_prettypr,lay_map,2,\n [{file,\n "c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_pre
21:04:01.346 [error] Process #PID<0.18900.0> raised an exception
ttypr.erl"},\n {line,614}]},\n {cerl_prettypr,lay_ann,2,\n [{file,\n "c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_prettypr.erl"},\n
** (ArgumentError) argument error
{line,413}]},\n {cerl_prettypr,format,2,\n [{file,\n "c:/ldisk/daily_build/18_opu_c.2015-12-17_21/otp_src_18/lib/hipe/cerl/cerl_prettypr.erl"},\n {line,273}]},\n
(stdlib) :ets.lookup(4505653, {:in, {Logger.Formatter, :prune, 1}})
{dialyzer_dataflow,format_args_1,3,\n [{file,"dialyzer_dataflow.erl"},{line,3350}]},\n {dialyzer_dataflow,format_args,3,\n [{file,"dialyzer_dataflow.erl"},{line,3343}]},\n
(stdlib) digraph.erl:225: :digraph.in_neighbours/2
{dialyzer_dataflow,get_apply_fail_msg,10,\n [{file,"dialyzer_dataflow.erl"},{line,603}]},\n {dialyzer_dataflow,handle_apply_or_call,9,\n [{file,"dialyzer_dataflow.erl"},{line,544}
dialyzer_callgraph.erl:571: :dialyzer_callgraph.digraph_in_neighbours/2
]}]}\nLast messages in the log cache:\n Reading files and computing callgraph... done in 8.45 secs\n Removing edges... done in 0.16 secs'}
dialyzer_dataflow.erl:3125: :dialyzer_dataflow.state__add_work_from_fun/2
dialyzer_cl.erl:704: :dialyzer_cl.cl_error/2
dialyzer_dataflow.erl:232: :dialyzer_dataflow.analyze_loop/1
dialyzer_cl.erl:406: :dialyzer_cl.do_analysis/4
dialyzer_dataflow.erl:174: :dialyzer_dataflow.analyze_module/6
dialyzer.erl:167: :dialyzer.run/1
dialyzer_dataflow.erl:159: :dialyzer_dataflow.get_fun_types/5
lib/dialyxir/plt.ex:166: Dialyxir.Plt.plt_add/2
dialyzer_succ_typings.erl:264: :dialyzer_succ_typings.refine_one_module/2
lib/dialyxir/plt.ex:41: Dialyxir.Plt.check_plt/4
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
lib/dialyxir/plt.ex:28: Dialyxir.Plt.check_plts/1
lib/mix/tasks/dialyzer.ex:128: Mix.Tasks.Dialyzer.check_plt/0
21:04:01.346 [error] Process #PID<0.19053.0> raised an exception
** (ArgumentError) argument error
(stdlib) :ets.lookup(4505653, {:in, {Logger, :reset_metadata, 0}})
(stdlib) digraph.erl:225: :digraph.in_neighbours/2
dialyzer_callgraph.erl:571: :dialyzer_callgraph.digraph_in_neighbours/2
dialyzer_dataflow.erl:3125: :dialyzer_dataflow.state__add_work_from_fun/2
dialyzer_dataflow.erl:232: :dialyzer_dataflow.analyze_loop/1
dialyzer_dataflow.erl:174: :dialyzer_dataflow.analyze_module/6
dialyzer_dataflow.erl:159: :dialyzer_dataflow.get_fun_types/5
dialyzer_succ_typings.erl:264: :dialyzer_succ_typings.refine_one_module/2
any ideas?
Adding Dialyxir as a mix dependency only adds the mix dialyzer
task, but not mix dialyzer.plt
. In the meantime, I've manually added mix dialyzer.plt
to one of my projects by yanking some code from Mix.Tasks.Dialyzer
.
This is useful in environments like CircleCI where I want mix dialyzer
run in my test phase, but mix dialyzer.plt
run in my dependencies phase where its output can be cached.
This would be preferable to having to install dialyzer globally so that I can run the commands separately.
Seems to be using an outdated syntax:
user@chrubuntu:~/src/dialyxir$ mix compile
== Compilation error on file lib/dialyzer.plt.ex ==
** (SyntaxError) lib/dialyzer.plt.ex:140: invalid token: ~w[eex elixir ex_unit iex mix]
(elixir) lib/kernel/parallel_compiler.ex:91: Kernel.ParallelCompiler."-spawn_compilers/8-fun-0-"/3
Is this a bug, or intentional?
Running mix dialyzer
, the exit code is 0
$ mix dialyzer
dialyzer --no_check_plt --fullpath --plt /Users/amorphid/my/code/github.com/amorphid/docker_hub/_build/dev/dialyxir_erlang-19.2_elixir-1.4.1_deps-dev.plt /Users/amorphid/my/code/github.com/amorphid/docker_hub/_build/dev/lib/docker_hub/ebin
Proceeding with analysis...
lib/docker_hub.ex:6: Invalid type specification for function 'Elixir.DockerHub':hello/0. The success typing is () -> 'world'
done in 0m2.88s
done (warnings were emitted)
$ echo $?
0
Running dialyzer
directly, the exit code is 2
$ dialyzer --no_check_plt --fullpath --plt
/Users/amorphid/my/code/github.com/amorphid/docker_hub/_build/dev/dialyxir_erlang-19.2_elixir-1.4.1_deps-dev.plt /Users/amorphid/my/code/github.com/amorphid/docker_hub/_build/dev/lib/docker_hub/ebin
Proceeding with analysis...
lib/docker_hub.ex:6: Invalid type specification for function 'Elixir.DockerHub':hello/0. The success typing is () -> 'world'
done in 0m2.88s
done (warnings were emitted)
$ echo $?
2
I was wondering what your thoughts were on 'prettying' up the output from dialyzer so that the warnings would stand out a bit more. I hacked together a crude approach here. Thoughts? :)
It seems that the dialyzer task itself doesn't recompile. Every time I change my code I have to recompile manually, or I get the same warnings. Shouldn't the task do this for me?
Thanks for sharing this! I'm just getting started and tried the configuration dialyzer: [plt_add_deps: true]
.
The first issue I ran into is that this seems to have no effect if updating an existing PLT. So I deleted the file to regenerate a new one.
The second issue is the command output from mix dialyzer.plt
appears to concatenate all -pa options into one string:
dialyzer --output_plt /Users/JC/.dialyxir_core_17_1.0.5.plt --build_plt -padeps/phoenix/ebin-padeps/phoenix_html/ebin-padeps/phoenix_ecto/ebin-padeps/postgrex/ebin-padeps/phoenix_live_reload/ebin-padeps/cowboy/ebin --apps erts kernel stdlib crypto public_key phoenix phoenix_html phoenix_ecto postgrex phoenix_live_reload cowboy -r /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../eex/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../elixir/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../ex_unit/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../iex/ebin /usr/local/Cellar/elixir/1.0.5/bin/../lib/elixir/../mix/ebin
(As an aside the correct paths are actually _build/dev/lib/..., so an option to the root deps path might make sense as well).
Am I doing something wrong or is this a bug? I'm on OSX 10.10.4, Elixir 1.0.5
I’m running into this issue when trying to run mix dialyze
on my CI service (CircleCI in this case) while everything seems fine locally. It points to this line but I can’t tell what’s wrong, since :erlang.system_info(:otp_release)
(here) returns the same '19'
for me, locally.
Checking PLT...
[:compiler, :connection, :cowboy, :cowlib, :crypto, :db_connection, :decimal,
:ecto, :eex, :elixir, :gettext, :kernel, :logger, :mime, :phoenix,
:phoenix_ecto, :phoenix_html, :phoenix_pubsub, :plug, :poison, :poolboy,
:postgrex, :ranch, :stdlib]
** (ArgumentError) argument error
:erlang.byte_size('19')
lib/dialyxir/project.ex:64: Dialyxir.Project.erlang_plt/0
lib/dialyxir/project.ex:7: Dialyxir.Project.plts_list/2
lib/mix/tasks/dialyzer.ex:128: Mix.Tasks.Dialyzer.check_plt/0
lib/mix/tasks/dialyzer.ex:110: Mix.Tasks.Dialyzer.run/1
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/task.ex:326: Mix.Task.run_alias/3
(mix) lib/mix/task.ex:259: Mix.Task.run/2
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:370: Code.require_file/2
Any clue as to what’s going on?
For CI-caching I do need to save the core PLT file at a different location than $HOME
. It seems that plt_core_path: ".cache/"
is ignored, and still the PLT files from whereever are taken into account, I can't even find something in $HOME
, but mix dialyzer
complains if it is not set...
If you set in mix.exs dialyzer: [ignore_warnings: "dialyzer.ignore-warnings"]
and use and empty dialyzer.ignore-warnings, it will crash on mix dialyzer
.
It'd be nice if this could be updated to work with the latest elixir.
the --halt-exit-status
flag that was added in #33 always returns the dialzyxir exit code, even if it's 0 and other tasks returned non zero codes. In our case, we have a mix ci
task, which runs our test, dogma and dialyzer tasks. When tests fail, we get an exit code of 0.
I'm trying to build the PTL but i get an error on mix dialyzer.plt
:
Starting PLT Core Build ... this will take awhile
dialyzer --output_plt /root/.dialyxir_core_18_1.0.5.plt --build_plt --apps erts kernel stdlib crypto public_key -r /elixir/bin/../lib/elixir/../eex/ebin /elixir/bin/../lib/elixir/../elixir/ebin /elixir/bin/../lib/elixir/../ex_unit/ebin /elixir/bin/../lib/elixir/../iex/ebin /elixir/bin/../lib/elixir/../mix/ebin
Compiling some key modules to native code... done in 0m37.73s
Creating PLT /root/.dialyxir_core_18_1.0.5.plt ...
dialyzer: Analysis failed with error:
Could not scan the following file(s):
Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.NoTaskError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.NoProjectError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.InvalidTaskError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Error.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.ElixirVersionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Dep.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../mix/ebin/Elixir.Mix.Config.LoadError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../iex/ebin/Elixir.IEx.State.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.TimeoutError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.TestCase.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.Test.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.DocTest.Error.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../ex_unit/ebin/Elixir.ExUnit.AssertionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Version.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Version.Requirement.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Version.InvalidVersionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Version.InvalidRequirementError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.UnicodeConversionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.UndefinedFunctionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.URI.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.TryClauseError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.TokenMissingError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Task.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.SystemLimitError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.System.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.SyntaxError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Supervisor.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Stream.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.RuntimeError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Regex.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Regex.CompileError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Range.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Protocol.UndefinedError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.MatchError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Macro.Env.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.KeyError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Inspect.Opts.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.IO.StreamError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.IO.Stream.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.HashSet.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.HashDict.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.FunctionClauseError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.GenEvent.Stream.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.File.Error.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.File.CopyError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.File.Stream.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.File.Stat.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Exception.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.ErlangError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Enum.OutOfBoundsError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Enum.EmptyError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.CompileError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.CondClauseError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.Code.LoadError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.CaseClauseError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.BadStructError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.BadMapError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.BadFunctionError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.BadArityError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.ArithmeticError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../elixir/ebin/Elixir.ArgumentError.beam Could not get core Erlang code for: /elixir/bin/../lib/elixir/../eex/ebin/Elixir.EEx.SyntaxError.beam
Last messages in the log cache:
Reading files and computing callgraph...
** (FunctionClauseError) no function clause matching in Keyword.get/3
(elixir) lib/keyword.ex:118: Keyword.get(:no_such_file, :files, nil)
lib/mix/tasks/dialyzer.plt.ex:132: Mix.Tasks.Dialyzer.Plt.core_plt_contains?/2
lib/mix/tasks/dialyzer.plt.ex:123: anonymous fn/1 in Mix.Tasks.Dialyzer.Plt.missing_apps/0
(elixir) lib/enum.ex:662: anonymous fn/3 in Enum.filter/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:662: Enum.filter/2
lib/mix/tasks/dialyzer.plt.ex:106: Mix.Tasks.Dialyzer.Plt.need_add?/0
lib/mix/tasks/dialyzer.plt.ex:57: Mix.Tasks.Dialyzer.Plt.run/1
I'm guessing there is something wrong with my erlang/elixir install but I am not sure where to ask for help.
The Dockerfiles for this are
here: https://github.com/sdwolf/dockerfile-elixir/blob/master/elixir/Dockerfile
and here: https://github.com/sdwolf/dockerfile-elixir/blob/master/elixir-dev/Dockerfile
Any hint on how to solve this is highly appreciated!
Presently dialyxir
shells out to the dialyzer
command line program to perform analysis. This is undesirable because it imposes the cost of launching a whole VM just to perform analysis. This was not a conscious decision but simply a reflection of the fact that dialyxir
began its life as the barest evolution of a shell script I'd been using.
The Erlang API documentation is fairly straightforward. We have to build up a data structure containing all the required options and pass them to the :dialyzer.run
function.
There is a working example in the dialyze project, the most relevant code:
...
plt_run([analysis_type: :succ_typings, plts: [plt], files: files,
warnings: warnings])
defp plt_run(opts) do
:dialyzer.run([check_plt: false] ++ opts)
end
You can see how they are structured at the bottom of the Erlang doc, you'll having a list of {:warning_name, {'filename', linenumber}, msg}. dialyzer
just prints them; of course we want to keep them colorized but it will be easier to have different color/styling for the the filename, line number, warning summary and the message itself.
We can also group by module/file in some way visually, so that warnings from a single file visually fit together and down the line there might be something useful we could do knowing the categories of errors that user just saw; such as making it easier for them to find help info.
:unknown
as one of the options.flags: ["-Wno..."]
in their mix.exs or passing them on the command line. Any command line parameter that dialyxir
isn't looking for just gets passed along to dialyzer
.Number 2 is a little tricky but I think we have to map the flags to the atom names to do what the user means. e.g. we have to map "-Wno_unused" to :no_unused
. We also want to let the user pass us atoms, e.g. they could have dialyzer: flags: [:no_unused, :unmatched_returns]
in their Mix project.
If we have to break strict compatibility we can - we'd make this the primary feature of the 0.5
release. But we should do what we can to keep likely configurations working after the update.
Having the full path makes it easier to integrate with some emacs modes (and no doubt other things). Being able to specify -fullpath would be nice.
I have the project structure like this:
lib
abcd
protocol.ex
efgh
protocol.ex
ijkl
protocol.ex
Elixir allow this, it is awesome!
When I run mix dialyzer
I see a warning:
...
protocol.ex:230: The pattern {'error', _error@1} can never match the type 'ok'
...
but I cannot say certain, which of protocol.ex
files affected.
Could you please add the full path to files? May be from the current directory.
While building a plt dialyzer itself threw an error:
** (throw) {:dialyzer_error, [67, 111, 117, 108, 100, 32, 110, 111, 116, 32, 103, 101, 116, 32, 97, 98, 115, 116, 114, 97, 99, 116, 32, 99, 111, 100, 101, 32, 102, 111, 114, 32, 102, 105, 108, 101, 58, 32, 'c:/Users/<user>/Projects/<project>/_build/dev/lib/relx/ebin/relx.beam', 32, 40, 112, 108, 101, 97, 115, 101, 32, 114, ...]}
dialyzer_plt.erl:469: :dialyzer_plt.compute_md5_from_file/1
dialyzer_plt.erl:436: :dialyzer_plt.compute_new_md5_1/3
dialyzer_plt.erl:406: :dialyzer_plt.check_plt/3
dialyzer_cl.erl:254: :dialyzer_cl.check_plt/3
dialyzer_cl.erl:187: :dialyzer_cl.plt_common/3
dialyzer.erl:167: :dialyzer.run/1
lib/dialyxir/plt.ex:166: Dialyxir.Plt.plt_add/2
lib/dialyxir/plt.ex:41: Dialyxir.Plt.check_plt/4
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
lib/dialyxir/plt.ex:28: Dialyxir.Plt.check_plts/1
lib/mix/tasks/dialyzer.ex:128: Mix.Tasks.Dialyzer.check_plt/0
lib/mix/tasks/dialyzer.ex:110: Mix.Tasks.Dialyzer.run/1
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:370: Code.require_file/2
That error should probably be caught and pretty-printed (or at least iolist-to-binary'd) so we know what happened. :-)
dialyzer: Analysis failed with error:
{{case_clause,#{'struct' => 'Elixir.Regex',
opts => <<>>,
re_pattern => {re_pattern,0,0,0,
<<69,82,67,80,73,0,0,0,0,0,0,0,17,8,0,0,255,255,
255,255,255,255,255,255,10,0,0,0,0,0,0,0,0,0,64,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,125,0,5,29,10,114,0,5,0>>},
source => <<"\n">>}},
[{cerl_prettypr,lay_literal,2,[{file,"cerl_prettypr.erl"},{line,468}]},
{cerl_prettypr,lay_ann,2,[{file,"cerl_prettypr.erl"},{line,411}]},
{cerl_prettypr,format,2,[{file,"cerl_prettypr.erl"},{line,271}]}]}
Last messages in the log cache:
Reading files and computing callgraph... done in 4.66 secs
Removing edges... done in 0.11 secs
** (FunctionClauseError) no function clause matching in Keyword.get/3
(elixir) lib/keyword.ex:118: Keyword.get(:no_such_file, :files, nil)
lib/mix/tasks/dialyzer.plt.ex:132: Mix.Tasks.Dialyzer.Plt.core_plt_contains?/2
lib/mix/tasks/dialyzer.plt.ex:123: anonymous fn/1 in Mix.Tasks.Dialyzer.Plt.missing_apps/0
(elixir) lib/enum.ex:647: Enum."-filter/2-lc$^0/1-0-"/2
lib/mix/tasks/dialyzer.plt.ex:106: Mix.Tasks.Dialyzer.Plt.need_add?/0
lib/mix/tasks/dialyzer.plt.ex:57: Mix.Tasks.Dialyzer.Plt.run/1
(mix) lib/mix/cli.ex:64: Mix.CLI.run_task/2
Hello,
I think I found a bug in dialyxir.
When I install dialyxir as mentioned and don't create the plt inside the repository, but inside a software I want to test, which has the attribute plt_add_apps: true
set, it builds the plt with including all dependencies and its paths in _build/dev/lib
just fine and works well.
When I instead create a plt in dialyxir with mix dialyzer.plt
first and then try to redo this command in the project I want to test, i get the following result
$ mix dialyzer.plt
Some apps are missing and will be added:
phoenix ecto phoenix_ecto mariaex ...
Adding Erlang/OTP Apps to existing PLT ... this will take a little time
dialyzer --add_to_plt --plt /Users/tobias/.dialyxir_core_18_1.1.1.plt --apps phoenix ecto phoenix_ecto mariaex ...
dialyzer: No such file, directory or application: "phoenix"
mix dialyzer.plt 14.72s user 0.48s system 100% cpu 15.140 total
So it seems, that when dialyxir is adding modules to the plt instead of creating it initially, it forgets all -pa
parameters.
Cheers,
Tobias
It would be nice to be able to add my local dependencies to the plt. Unfortunately, there is no way to ad '-pa ./deps/*/ebin' to the plt dializer command line. I don't think it would hurt anything to add that by default. Then I could list both apps from the distribution and apps from my dependencies in the plt_apps.
I was hoping to get dialyzer worked into my CI, but noticed that mix dialyzer
always exits with 0, which means it's eating up the actual exit status.
0 - No problems were encountered during the analysis and no warnings were emitted. 1 - Problems were encountered during the analysis. 2 - No problems were encountered, but warnings were emitted.
If I do a mix deps.update some-lib
and then run mix dialyzer.plt
it shows me
==> some-lib (compile)
Compiled src/api/some_api.erl
Nothing to do.
which is alright cause I did change some specs in some_api.erl
However, if I run mix dialyzer
now, the spec change in some-lib doesn't take effect until I rm -rf ~/.dialyxir_core_*
and run mix dialyzer.plt
again.
I guess this should worth a bug report?
btw I use dialyzer: [plt_add_deps: true],
in my mix.exs if that matters.
It seems that the dependency list is built from the mix project dependencies (https://github.com/jeremyjh/dialyxir/blob/master/lib/mix/tasks/dialyzer.plt.ex#L97-L101). However this does not include nested dependencies.
It seems like it could get the full dependency list from the mix.lock
file instead, but I'm not sure if this was a consideration that you may have already had. Is there a reason it is not doing this currently?
The fallback for otp_vsn()
is :erlang.system_info(:otp_release)
. The result of that is concatenated with a string. The issue is :erlang.system_info(:otp_release)
returns a char list.
> i :erlang.system_info(:otp_release)
...
Data type
List
...
> "erlang-" <> :erlang.system_info(:otp_release)
** (ArgumentError) argument error
It took me a while to find them. It would be nice to have them in the readme.
I've been following the steps in https://github.com/jeremyjh/dialyxir/wiki/Phoenix-Dialyxir-Quickstart for a brand new phoenix project, but all the errors I run into when running mix dialyzer
are not mentioned there. The following is the complete output of mix dialyzer
for reference:
$ mix dialyzer
Checking PLT...
[:asn1, :bunt, :compiler, :connection, :cowboy, :cowlib, :credo, :crypto,
:db_connection, :decimal, :dialyxir, :ecto, :eex, :elixir, :gettext, :kernel,
:logger, :mime, :phoenix, :phoenix_ecto, :phoenix_pubsub, :plug, :poison,
:poolboy, :postgrex, :public_key, :ranch, :ssl, :stdlib]
PLT is up to date!
Starting Dialyzer
dialyzer args: [check_plt: false,
init_plt: '/apps/my_app/master/_build/dev/dialyxir_erlang-19.1_elixir-1.4.2_deps-dev.plt',
files_rec: ['/apps/my_app/master/_build/dev/lib/my_app/ebin'],
warnings: [:unknown]]
done in 0m4.36s
:0: Unknown function 'Elixir.Endpoint':config_change/2
lib/phoenix/router.ex:2: Function dispatch/2 will never be called
lib/phoenix/router.ex:2: Function match_route/2 has no local return
web/router.ex:1: Function segments/3 will never be called
done (warnings were emitted)
Here are the various versions at play:
Erlang version: 19.1
Elixir version: 1.4.2
Phoenix version: 1.2.1
What is the best way to resolve these issues?
It would be nice to have access to the exit status of the dialyzer run, to have the benefit of using mix for it in CI (or any scripted environment).
My dialyzer section has the following lines:
dialyzer: [ plt_apps: [ :erts, :kernel, :stdlib,
:crypto,
:ecto, :postgrex, :poison,
:maru, :plug
],
However I see some functions from crypto
module in warnings output:
Unknown functions:
crypto:block_decrypt/4
crypto:block_encrypt/4
crypto:hash/2
crypto:rand_bytes/1
crypto:strong_rand_bytes/1
Hello,
I've tried to use Dialyxir and it works I think (I see errors/warning about my project.)
But under analysis of my project there is
Unknown functions:
'Elixir.Calendar.DateTime':'advance!'/2
'Elixir.Calendar.DateTime':now_utc/0
'Elixir.Ecto':build_assoc/2
'Elixir.Ecto.Adapters.Postgres':rollback/2
'Elixir.Ecto.Adapters.Postgres':stop/3
'Elixir.Ecto.Adapters.Postgres':transaction/3
'Elixir.Ecto.Changeset':cast/4
'Elixir.Ecto.Changeset':get_change/2
The list goes on.
I've googled around and found I have to add the deps to dialyzer: path
. After adding ecto
and plug
and running mix dialyzer
, it eats all of my remaining memory (7GB) and then keeps eating away swap. I've stopped it when it took 9GB.
It even eats all of my memory when I add just ecto
.
I added it in mix.exs like this
dialyzer: [
paths: [
"_build/dev/lib/ecto/ebin"
]
]
Am I doing it wrong or is it normal that it eats 9GB memory for my small project?
Thanks
Hello, I'm getting this error on Ubuntu 15.10 with Elixir 1.2.3:
sashaafm@ubuntu:~/Documents/dialyxir$ mix dialyzer.plt
Starting PLT Core Build ... this will take awhile
dialyzer --output_plt /home/sashaafm/.dialyxir_core_18_1.2.3.plt --build_plt --apps erts kernel stdlib crypto public_key -r /usr/local/lib/elixir/bin/../lib/elixir/../eex/ebin /usr/local/lib/elixir/bin/../lib/elixir/../elixir/ebin /usr/local/lib/elixir/bin/../lib/elixir/../ex_unit/ebin /usr/local/lib/elixir/bin/../lib/elixir/../iex/ebin /usr/local/lib/elixir/bin/../lib/elixir/../logger/ebin /usr/local/lib/elixir/bin/../lib/elixir/../mix/ebin
** (ErlangError) erlang error: :enoent
(elixir) lib/system.ex:450: System.cmd("dialyzer", ["--output_plt", "/home/sashaafm/.dialyxir_core_18_1.2.3.plt", "--build_plt", "--apps", "erts", "kernel", "stdlib", "crypto", "public_key", "-r", "/usr/local/lib/elixir/bin/../lib/elixir/../eex/ebin", "/usr/local/lib/elixir/bin/../lib/elixir/../elixir/ebin", "/usr/local/lib/elixir/bin/../lib/elixir/../ex_unit/ebin", "/usr/local/lib/elixir/bin/../lib/elixir/../iex/ebin", "/usr/local/lib/elixir/bin/../lib/elixir/../logger/ebin", "/usr/local/lib/elixir/bin/../lib/elixir/../mix/ebin"], [])
lib/mix/tasks/dialyzer.plt.ex:72: Mix.Tasks.Dialyzer.Plt.build_plt/0
lib/mix/tasks/dialyzer.plt.ex:56: Mix.Tasks.Dialyzer.Plt.run/1
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:363: Code.require_file/2
I tried to install it on another machine with the exact same Ubuntu set up and Elixir version and it worked. Erlang versions are also the same I think.
uniaika 00:24 (master ) ~/repos/Repox/dialyxir ❯❯ mix dialyzer.plt
Starting PLT Core Build ... this will take awhile
dialyzer --output_plt /home/uniaika/.dialyxir_core_18_1.0.5.plt --build_plt --apps erts kernel stdlib crypto public_key -r /usr/lib64/elixir/bin/../lib/elixir/../eex/ebin /usr/lib64/elixir/bin/../lib/elixir/../elixir/ebin /usr/lib64/elixir/bin/../lib/elixir/../ex_unit/ebin /usr/lib64/elixir/bin/../lib/elixir/../iex/ebin /usr/lib64/elixir/bin/../lib/elixir/../mix/ebin
Compiling some key modules to native code...{"init terminating in do_boot",{{badmatch,ok},[{dialyzer_cl,hc_cache,1,[{file,"dialyzer_cl.erl"},{line,573}]},{lists,foreach,2,[{file,"lists.erl"},{line,1337}]},{dialyzer_cl,hipe_compile,2,[{file,"dialyzer_cl.erl"},{line,517}]},{dialyzer_cl,do_analysis,4,[{file,"dialyzer_cl.erl"},{line,383}]},{dialyzer,'-cl/1-fun-0-',1,[{file,"dialyzer.erl"},{line,153}]},{dialyzer,doit,1,[{file,"dialyzer.erl"},{line,243}]},{dialyzer,plain_cl,0,[{file,"dialyzer.erl"},{line,84}]},{init,start_it,1,[]}]}}
** (FunctionClauseError) no function clause matching in Keyword.get/3
(elixir) lib/keyword.ex:118: Keyword.get(:no_such_file, :files, nil)
lib/mix/tasks/dialyzer.plt.ex:132: Mix.Tasks.Dialyzer.Plt.core_plt_contains?/2
lib/mix/tasks/dialyzer.plt.ex:123: anonymous fn/1 in Mix.Tasks.Dialyzer.Plt.missing_apps/0
(elixir) lib/enum.ex:662: anonymous fn/3 in Enum.filter/2
(elixir) lib/enum.ex:1261: Enum."-reduce/3-lists^foldl/2-0-"/3
(elixir) lib/enum.ex:662: Enum.filter/2
lib/mix/tasks/dialyzer.plt.ex:106: Mix.Tasks.Dialyzer.Plt.need_add?/0
lib/mix/tasks/dialyzer.plt.ex:57: Mix.Tasks.Dialyzer.Plt.run/1
Hi!
Looks like OTP guys stopped increasing otp_release number.
Eg. 17.1 has actually still "17" when you call erlang:system_info(otp_release).
This screws up your check in plt_file()
So maybe another kind of check is needed.
I also don't have any idea if this is intented behavior in OTP and it will continue in the whole 17.x line, or not.
Any ideas? :)
Setting
dialyzer: [plt_add_deps: :transitive, plt_add_apps: [:inets], ignore_warnings: ".dialyzerignore"]
in a phoenix project with the .dialyzerignore
file in place, calling
mix dialyzer --halt-exit-status
shows no warnings but returns an exit status > 0.
Using dialyxir 0.4.4
When I run mix dialyze
using dialyxir I get the following error
Finding suitable PLTs
Looking up modules in dialyxir_erlang-19.2_elixir-1.4.1_deps-dev.plt
Looking up modules in dialyxir_erlang-19.2_elixir-1.4.1.plt
Looking up modules in dialyxir_erlang-19.2.plt
Finding applications for dialyxir_erlang-19.2.plt
Finding modules for dialyxir_erlang-19.2.plt
Creating dialyxir_erlang-19.2.plt
** (throw) {:dialyzer_error, [67, 111, 117, 108, 100, 32, 110, 111, 116, 32, 103, 101, 116, 32, 97, 98, 115, 116, 114, 97, 99, 116, 32, 99, 111, 100, 101, 32, 102, 111, 114, 32, 102, 105, 108, 101, 58, 32, '/usr/lib/erlang/lib/erts-8.2/ebin/erlang.beam', 32, 40, 112, 108, 101, 97, 115, 101, 32, 114, ...]}
dialyzer_plt.erl:469: :dialyzer_plt.compute_md5_from_file/1
dialyzer_plt.erl:458: :dialyzer_plt."-compute_md5_from_files/1-lc$^0/1-0-"/1
dialyzer_plt.erl:458: :dialyzer_plt."-compute_md5_from_files/1-lc$^0/1-0-"/1
dialyzer_plt.erl:458: :dialyzer_plt.compute_md5_from_files/1
dialyzer_cl.erl:74: :dialyzer_cl.build_plt/1
dialyzer.erl:167: :dialyzer.run/1
lib/dialyxir/plt.ex:148: Dialyxir.Plt.plt_new/1
lib/dialyxir/plt.ex:120: Dialyxir.Plt.check_beams/4
lib/dialyxir/plt.ex:41: Dialyxir.Plt.check_plt/4
(elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
lib/dialyxir/plt.ex:28: Dialyxir.Plt.check_plts/1
lib/mix/tasks/dialyzer.ex:128: Mix.Tasks.Dialyzer.check_plt/0
lib/mix/tasks/dialyzer.ex:110: Mix.Tasks.Dialyzer.run/1
(mix) lib/mix/task.ex:294: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
(elixir) lib/code.ex:370: Code.require_file/2
Since this fails before reaching any of my application's code, I'd asume it's either installation issue, or a bug in dialyxir?
I'm using Elixir 1.4.1 with Erlang 19 on arch linux installed via pacman.
Version 0.5.0
def project do
[
...
dialyzer: [
plt_add_deps: :transitive,
ignore_warnings: "dialyzer.ignore-warnings",
flags: ["--quiet"]
]
]
end
Running:
mix dialyzer
Compiling 23 files (.ex)
Generated efrontback app
Checking PLT...
[skipped]
PLT is up to date!
Starting Dialyzer
dialyzer args: [check_plt: false,
init_plt: 'skipped',
files_rec: ['skipped'],
warnings: [:quiet, :unknown]]
:dialyzer.run error: Unknown dialyzer warning option: quiet
The docs say: You can specify any dialyzer
command line argument with the :flags keyword.
Am I missing anything?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.