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
5
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,918
  • 1
  • 19
  • 18
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
  • 11,924
  • 15
  • 75
  • 120
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
  • 6,450
  • 2
  • 27
  • 38
4
votes
1 answer

Dialyzer warns about no_exit on bad record construction - is this a bug?

When Dialyzer encounters a record literal where a required field is not initialized, it thinks control flow stops at the line with the record literal. Example: -module(sample). -export([foo/0]). -record(boo, {a :: number()}). foo() -> …
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
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
  • 14,346
  • 12
  • 59
  • 97
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
  • 9,129
  • 1
  • 27
  • 51
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
  • 39,593
  • 22
  • 116
  • 167
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
  • 15,512
  • 17
  • 62
  • 81
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
  • 143
  • 6
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
  • 23,261
  • 7
  • 71
  • 99
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
  • 3,205
  • 1
  • 29
  • 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,117
  • 1
  • 15
  • 32
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
  • 14,346
  • 12
  • 59
  • 97
3
votes
1 answer

What does PLT stand for?

I've been using Dialyzer (and Dialyxir) on a big Elixir code base, and when I run it, it spits out a bunch of diagnostic information. It references .plt files a lot. What does "PLT" stand for in the context of Erlang and Dialyzer?
Ashton Wiersdorf
  • 1,865
  • 12
  • 33
3
votes
1 answer

Dializer (via Dialyxir) warning about "but this value is unmatched" from `forward` command for Absinthe (GraphQL) route. How to address?

I am getting a dialyzer error about unmatched returns of which I'm not sure how to properly address. mix dialyzer --quiet lib/my_app_web/router.ex:1:no_return Function __checks__/0 has no local…
Loading...
  • 863
  • 9
  • 21