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

"dialyzer: Analysis failed with error.." (dialyzer bug? or wrong use of map-type?)

Working on a very simple application in my progress of learning elixir, I ran into a minor roadblock when checking the types with dialyzer. Running dialyzer on my code results in an Analysis failed error... So far dialyzer has only given me warnings…
Michelrandahl
  • 3,365
  • 2
  • 26
  • 41
2
votes
1 answer

Erlang Dialyzer: only accept certain integers?

Say I have a function,foo/1, whose spec is -spec foo(atom()) -> #r{}., where #r{} is a record defined as -record(r, {a :: 1..789})., however, I have foo(a) -> 800. in my code, when I run dialyzer against it, it didn't warn me about this, (800 is not…
Not an ID
  • 2,579
  • 2
  • 21
  • 28
2
votes
1 answer

Type errors in dialyzer in function with specified type

I am receiving an error in dialyzer when it analyzes the following function. -spec do_request(Method, Type, Url, Expect, Headers, Body, Client) -> Response::client_response() when Method :: method(), Type :: content_type(), Url …
dethtron5000
  • 10,363
  • 1
  • 31
  • 32
2
votes
1 answer

Can Dialyzer see through Mnesia transaction functions?

Here is some code with an error which I think Dialyzer should be able to spot: -module(myapp_thing). -spec exists(pos_integer()) -> yes | no. exists(Id) -> myapp_mnesia:thing_exists(Id).   -module(myapp_mnesia). thing_exists(Id) -> Exists…
Ivan Uemlianin
  • 953
  • 7
  • 21
2
votes
1 answer

Why does dialyzer find my type specification invalid?

I am new to dialyzer, and I am hoping someone could give me a quick idea of it's operation by answering this question. I would think that the following function, given a number X and a non-negative integer N, would produce a number. (X to the Nth…
njlarsson
  • 2,128
  • 1
  • 18
  • 27
1
vote
0 answers

How to specify arguments and return types for functions within functions using the Erlang Dialyzer?

How do you specify arguments and return types type for functions within functions using the Erlang Dialyzer, such as functions from libraries or Behavior (e.g gen_servers gen_server:reply/2). For instance in the MVR code provided below, how can I…
Piskator
  • 605
  • 1
  • 9
1
vote
0 answers

Why doesn't Erlang's Dialyzer detect difference in state?

I run Dialyzer on the following MVR piece of code which passes the test_function except for the IncorrectMap. Why is that the case when I deliberately return different PlayersMapNew for the case branches although they are specified to be the same.…
Piskator
  • 605
  • 1
  • 9
1
vote
0 answers

Different behaviour when producing annotations with Erlang Typer

I am using the typer_core module of Dialyzer to automatically infer typespecs. However, I am obtaining different behaviour based on whether the files specified are prepended with the . character or not. The behaviour described below only affects…
Duncan Paul
  • 485
  • 5
  • 13
1
vote
1 answer

What are the requirements for position of custom attributes in an Erlang module?

It seems: Dialyzer and erlc both error when there is a user-defined attribute in a source file before -module Shell session demonstrating: ~ cat sample.erl -my_attr(my_value). -module(sample). -compile([export_all, nowarn_export_all]). main(_)…
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
1
vote
1 answer

Dialyzer does not catch errors on returned functions

Background While playing around with dialyzer, typespecs and currying, I was able to create an example of a false positive in dialyzer. For the purposes of this MWE, I am using diallyxir (versions included) because it makes my life easier. The…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
1
vote
1 answer

Elixir Behaviour that returns the implementer's struct type

I have a behaviour to abstract over parsing URL query parameters for various Phoenix endpoints. It looks like this: defmodule Query do @callback from_query_params(params :: %{optional(String.t()) => any()}) :: {:ok, parsed :: struct}…
s3cur3
  • 2,749
  • 2
  • 27
  • 42
1
vote
1 answer

How to ignore "ifdef(TEST)" in Dialyzer?

I tried to use the define macro flag like this: dialyzer -dNOTEST, and it did not work. Does anyone have workaround?
Yoshi
  • 405
  • 4
  • 12
1
vote
0 answers

How do I fix dialyzer unknown_function errors from dependencies?

I have a large Elixir (1.7.4) application and am running dialyzer (with dialyxir's latest version). I get a lot of unknown_function errors for functions that seem to mostly be in modules nested under packages that I have in deps. I found How to fix…
Sinc
  • 553
  • 1
  • 8
  • 31
1
vote
1 answer

`changeset()` spec requires nullable type which is not logically nullable

I have the following code: defmodule Foo do @moduledoc false use Ecto.Schema import Ecto.Changeset @type t :: %__MODULE__{ id: integer(), foo: String.t(), baz_id: String.t(), bar: String.t() | nil …
norok2
  • 25,683
  • 4
  • 73
  • 99
1
vote
1 answer

What is Dialyzer with succ_typings false?

I thought Dialyzer was a tool for checking success typings. However, its public API has a succ_typings false option. Rebar3's Dialyzer provider exposes this via the --succ-typings false command line option. What is the difference between running…
Max Heiber
  • 14,346
  • 12
  • 59
  • 97