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
19
votes
1 answer

How to fix Dialyzer "Callback info about the '.....' behaviour is not available" error for new Mix.Tasks

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,…
prnsml
  • 1,454
  • 9
  • 16
13
votes
2 answers

How to avoid a “can never match” error from Dialyzer in a `with` statement that has a match all `else`?

I have the following code: @spec test_pass(String.t) :: (:failed | {:ok, map()}) def test_pass(pass) do db_user = %{password_hash: @hash_for_foo} with {:ok, ^db_user} <- Comeonin.Argon2.check_pass(db_user, pass) do {:ok, db_user} else …
Patrick J. S.
  • 2,750
  • 15
  • 25
11
votes
1 answer

How can I typespec for a single letter ASCII string (value 0-127)?

Equivalently, how can I typespec for a "single" UTF8 char? Within a type definition, I can have generic "any string" or "any utf8 string" with @type tile :: String.t # matches any string @type tile :: <<_::8>> # matches any single byte but it seems…
rewritten
  • 14,591
  • 2
  • 39
  • 48
8
votes
1 answer

Erlang: Will adding type spec to code make dialyzer more effective?

I have a project that doesn't have -spec or -type in code, currently dialyzer can find some warnings, most of them are in machine generated codes. Will adding type specs to code make dialyzer find more errors? Off the topic, is there any tool to…
Not an ID
  • 2,419
  • 1
  • 16
  • 25
7
votes
1 answer

Dialyzer says function will never be called, even though it is

I am using the elixir_talk library. After connecting I want to call a private function once connected to beanstalkd. I just added typespecs and ran Dialyzer (via dialyxir). I get the errors: my_module.ex:3: The specification for…
Will Sewell
  • 2,349
  • 1
  • 18
  • 35
7
votes
2 answers

How do I get dialyzer to ignore certain unexported functions?

I'm using lager to do my logging; it has a parser transform which converts lager:warn/1, etc. functions into lager:trace... functions. dialyzer doesn't process the parser transform, so it warns with Call to missing or unexported function…
Roger Lipscombe
  • 81,986
  • 49
  • 214
  • 348
7
votes
2 answers

Why Dialyzer tells me that this fun contract has overlapping domains?

I am reading with interest the online book "learn you some erlang" and trying some exercises to check my understanding. I made some modification on the fifo example, in the chapter Type Specifications and Erlang, trying to define a "typed_fifo(T)"…
Pascal
  • 13,632
  • 1
  • 20
  • 28
6
votes
1 answer

dialyzer not detecting guard violation when function is exported

Dialyzer version 2.9. Erts 7.3. OTP 18. In the following contrived erlang code: -module(dialBug). -export([test/0]). %-export([f1/1]). % uncomment this line test() -> f1(1). f1(X) when X > 5 -> X*2. When dialyzer is run over the above…
David J
  • 723
  • 5
  • 18
6
votes
1 answer

Does Dialyzer analyze anonymous functions?

In my progress of learning Elixir, I am playing around with Dialyzer to put types on my functions. In this regard, I've noticed that Dialyzer doesn't seem to check the types for anonymous functions. In the example below, I am passing an anonymous…
Michelrandahl
  • 2,895
  • 2
  • 22
  • 39
6
votes
2 answers

Why doesn't Dialyzer find this code wrong?

I've created the snippet below based on this tutorial. The last two lines (feed_squid(FeederRP) and feed_red_panda(FeederSquid)) are obviously violating the defined constraints, yet Dialyzer finds them okay. This is quite disappointing, because this…
Attila Kun
  • 1,975
  • 2
  • 21
  • 32
5
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
  • 10,336
  • 4
  • 47
  • 67
5
votes
2 answers

Dialyzer misses error with type specification

The following Erlang code seems to have an obvious error in its type specification, but dialyzer says that everything is ok. Am I misunderstanding or is this a bug in dialyzer? Running on Erlang 19.3 -module(foobar). -export([foo/1]). -spec…
5
votes
1 answer

Specifying a string value in the type definition for the Elixir typespecs

Is it possible to define a type as follows: defmodule Role do use Exnumerator, values: ["admin", "regular", "restricted"] @type t :: "admin" | "regular" | "restricted" @spec default() :: t def default() do "regular" end end to make…
smefju
  • 2,404
  • 19
  • 25
5
votes
2 answers

Type of non-terminating function in Erlang

I'm learning Erlang and trying to use Dialyzer to get maximum type-safety when it's possible. There's a thing that I don't understand: what is the type of non-terminating function and how to denote it in -spec. Could anyone shed some light on this?
ppopoff
  • 609
  • 7
  • 17
5
votes
1 answer

Why does Dialyzer not catch this simple error?

Dialyzer does not signal the inconsistency in the return type of this function: -spec myfun(integer()) -> zero | one. myfun(0) -> zero; myfun(1) -> one; myfun(2) -> other_number. but it detects in the case of the last line being myfun(_) ->…
mljrg
  • 3,545
  • 1
  • 27
  • 42
1
2 3 4 5 6 7