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

95 questions
5
votes
3 answers

static analysis vs static typing

I'm learning Elixir, and the tool 'dialyzer' lets you do static analysis - annotate the function definition with the type specification of the parameters it expects and the output it returns. It's completely optional, but if it were to be used to…
tldr
  • 10,743
  • 11
  • 69
  • 111
5
votes
1 answer

Erlang: dialyzer is dead slow for a big project

The Scalaris key-value store is a big Erlang project with ~100 modules. I am implementing a new module within this project and am struck by how long it takes for dialyzer to do one complete check of the project. A run of make dialyzer takes about…
evnu
  • 5,910
  • 2
  • 23
  • 36
4
votes
2 answers

Why does Dialyzer believe specs with too-specific return types?

I expect adding specs to never make things less safe, but that's exactly what happens in the following case. In the following code, Dialyzer (wrongly) trusts me that the return type of bar is 1. This leads it to saying that a pattern in foo() can…
Max Heiber
  • 10,336
  • 4
  • 47
  • 67
4
votes
1 answer

Caching on Heroku CI

I am setting up Heroku CI with Elixir Phoenix buildpack. I want to start using Dialyzer. Diazlyer is a static analysis tool that before the first run takes at least a couple of minutes to create a "persistent lookup table" (PLT) of types from…
tkowal
  • 8,659
  • 1
  • 20
  • 42
4
votes
2 answers

Does Rebar3 compile Dialyzer modules with HiPE?

When running Dialyzer stand-alone, it compiles its modules with HiPE, in order to speed up the analysis: dialyzer --src -r . Checking whether the PLT /home/foo/.dialyzer_plt is up-to-date... yes Compiling some key modules to native code... done…
legoscia
  • 37,068
  • 22
  • 103
  • 148
4
votes
1 answer

How to avoid Dialyzer errors for protocols?

A simple protocol yields two kinds of dialyzer warnings: defmodule Dtest do defprotocol Valid do @doc "Returns true if data is in a valid state" def valid?(data) end defimpl Valid, for: Integer do def valid?(_), do: true …
Dogweather
  • 12,603
  • 15
  • 54
  • 73
4
votes
1 answer

Elixir type specs and parameterized type variables

I am trying to figure out how to combine parameterized types and type variables in Elixir type and function specs. As a simple example, let's say I am defining a Stack module: defmodule Stack do @type t :: t(any) @type t(value) :: list(value) …
Jason Voegele
  • 1,898
  • 1
  • 18
  • 18
4
votes
1 answer

Erlang: NIFs and dialyzer warning

When implementing NIFs, Dialyzer gives me Function crc16/1 has no local return probably because I do exit in the .erl module (like the official docs recommend): -module(my_nifs). -export([crc16/1]). -on_load(init/0). init() -> ok =…
GabiMe
  • 16,471
  • 25
  • 71
  • 106
4
votes
2 answers

Is there any efficiency difference between using Dialyzer on Erlang beam and source code?

I collect all beam files of a project under a path like ~/erl_beam dialyzer ~/erl_beam/*.beam --get_warnings -o static_analysis.log It works well. If I do it on Erlang source code: dialyzer --get_warnings -I --src -o…
boeingdream
  • 133
  • 5
4
votes
3 answers

Can I tell Dialyzer to ignore some modules?

I'm building a PLT using dialyzer --output_plt lib.plt --build_plt --apps stdlib kernel mnesia ssl public_key crypto erts asn1 inets sasl odbc It spits out some errors about unknown functions in modules I don't care about. For example: …
Nathaniel Waisbrot
  • 19,061
  • 3
  • 65
  • 86
4
votes
1 answer

Having Dialyzer support Custom Behaviours

I am using Dialyzer with a few custom behaviors, the problem is that when I do that, Dialyzer gives me this error: src/max.erl:3: Callback info about the gen_strategy behaviour is not available One thing I can't figure out is how to create that…
Zachary K
  • 2,979
  • 1
  • 26
  • 36
3
votes
3 answers

Erlang Dialyzer PLT file portability between different architectures

Can you copy and use a Dialyzer PLT output to another machine of different architecture? For example, I've built a PLT file on an x86_64 Linux machine. Can I use the file on an x86 FreeBSD or a Windows machine?
jj1bdx
  • 1,057
  • 1
  • 15
  • 31
3
votes
1 answer

Is casting to `any()` a good solution for having Dialyzer accept ETS match patterns?

Is casting to any() a good solution for having Dialyzer accept ETS match patterns? Dialyzer and match specifications don't play well together, and there doesn't seem to be a standard…
Max Heiber
  • 10,336
  • 4
  • 47
  • 67
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
  • 1,773
  • 3
  • 12
  • 16
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