Questions tagged [dialyzer]

Dialyzer is a tool that detects discrepancies in programs written in Erlang.

Dialyzer is a tool that detects discrepancies in programs written in Erlang. These may be:

  1. Function calls that are certain to fail
  2. Clauses that will never match
  3. Errors in the type specifications of records and functions
  4. Violations of the opacity of certain data structures

It does not require any modification in the code under examination (but it can use any type annotations provided) and can efficiently analyze single modules, applications or whole systems. It is part of Erlang/OTP distribution and is actively maintained by its developers.

You can read more here: http://erlang.org/doc/man/dialyzer.html

109 questions
3
votes
1 answer

Dialyzer warnings about pattern_match_cov on Gettext module

I started using Dialyzer (dialyxir 1.0.0-rc.6) on my umbrella project based on Phoenix 1.4. When I ran mix dialyzer on it for the first time, I got this warning. apps/my_app/lib/my_app_web/gettext.ex:1:pattern_match_cov The pattern %{} can never…
Tsutomu
  • 4,848
  • 1
  • 46
  • 68
3
votes
2 answers

Is there a way to make Dialyzer watch code changes?

I'm using dialyxir which appends a dialyzer task to Mix. But it doesn't seem to have any --watch option that would rerun the type checking on file changes. Is there a CLI way to achieve that?
Ivan Gabriele
  • 6,433
  • 5
  • 39
  • 60
3
votes
1 answer

dialyzer fails to recognise elixir functions with error :0:unknown_function

I have elixir 1.7.2 on my computer installed using asdf, both elixir and erlang otp 21. On my project mix file I have added the latest release candidate of dialyzer as instructed on dialyzer github {:dialyxir, "~> 1.0.0-rc.3", only: [:dev],…
Sigu Magwa
  • 546
  • 5
  • 18
3
votes
0 answers

Can I use Dialyzer GUI or the dialyzer command line tool directly without dialyxir for elixir code?

I have an elixir project, on which when I run mix dialyzer (which calls dialyxir), I get a very small snippet of an error, and it becomes very difficult to trace the source of it. On dialyzer there are some additional format options available which…
saketrp
  • 2,323
  • 3
  • 16
  • 18
3
votes
1 answer

Erlang: Why Dialyzer does not notice this error?

Now, I try to use Dialyzer and use -spec, -type. I give the below code to Dialyzer, and I expected Dialyzer to notice "hoge(a) + 1 is invalid", but Dialyzer does not notice. -spec hoge (X) -> bad when X :: a; (X) -> number() when X…
oky
  • 65
  • 5
3
votes
1 answer

Typespecs for Arc.Ecto.changeset

I am copying Arc.Ecto changeset example https://github.com/stavro/arc_ecto and I am not sure about the typespecs, I am trying with these but doesnt seem to work for dialyzer, it complains on |> cast_attachments(params, [:avatar]) @spec…
lapinkoira
  • 8,320
  • 9
  • 51
  • 94
3
votes
1 answer

Elixir / Erlang Dialyzer : Why behaviour callback's param type should be subtype instead of supertype?

I have a behaviour X and a callback function with parameter type: %{a: any} Module Y implements behaviour X and the callback function in implementing module Y has parameter type: %{a: any, b: any} Dialyzer doesn't like that and…
Ahmad Ferdous
  • 3,351
  • 16
  • 33
3
votes
1 answer

Function arity as a result of default parameters in elixir making dialyzer complain

I have a function with 2 default parameters defp foo(bar, baz, qux \\ "", garply \\ nil) I’ve got two usages, one supplies only the first two parameters, the other all 4. Dialyzer is complaining that Function foo/3 will never be called. I assume…
kolosy
  • 3,029
  • 3
  • 29
  • 48
3
votes
2 answers

Erlang Dialyzer integer ranges

-module(test). -export([f/0, g/0]). -spec f() -> RESULT when RESULT :: 0..12 . -spec g() -> RESULT when RESULT :: 0..13 . f () -> 100 . g () -> 100 . Running dialyzer (and typer) only the function f is caught. dialyzer…
beoliver
  • 5,579
  • 5
  • 36
  • 72
3
votes
1 answer

Why Erlang Dialyzer cannot find type error in the following code?

free_vars_in_dterm({var, V}) -> {var, V}; obviously cannot type check, however, dialyzer says everything is OK. $ dialyzer *erl Checking whether the PLT ~/.dialyzer_plt is up-to-date... yes Proceeding with analysis... done in 0m0.66s done…
kainwen
  • 356
  • 1
  • 12
3
votes
0 answers

The created fun has no local return

Test under Erlang R15B. -spec parse_packet(integer(), binary()) -> list(). parse_packet(16013, <<0:16, _/binary>>) -> []; parse_packet(16013, <>) -> SizePerMount = byte_size(ListBin) div ListNum, (1)Fun = fun(_,…
goofansu
  • 2,277
  • 3
  • 30
  • 48
2
votes
1 answer

erlang dialyzer and extended modules

Dialyzer doesn't like calls to functions in the base module. Is there a dialyzer flag to skip this error or am I doing some wrong. Here is a similar code: -module(base). -export(foo/1). foo(X) ->…
cashmere
  • 2,811
  • 1
  • 23
  • 32
2
votes
1 answer

Dialyzer simplifies long union types

I've noticed that Dialyzer possibly simplifies long union types, at least when it comes to atoms. For example, if I have: defmodule Foo do @type name() :: :one | :two | :three @spec bar(name()) :: String.t() def bar(name), do:…
NoDisplayName
  • 15,246
  • 12
  • 62
  • 98
2
votes
1 answer

Dialyzer check only the first case of the function

Why does Dialyzer check only the first case of the function? -spec f(integer()) -> integer(). f(0) -> 0; f(_) -> test. Proceeding with analysis... done in 0m0.25s done (passed successfully) The version with "case" also passes the check: -spec…
2
votes
2 answers

Dialyzer cannot recognize error in function using polymorphic types

Background I am trying out polymorphic typing with dialyzer. As an example I am using the famous Option type (aka, Maybe Monad) that is now prevalent in many other languages these days. defmodule Test do @type option(t) :: some(t) | nothing …
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266