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

How to typespec guards in a human friendly way?

Background I am playing with guards and I want my guard definitions to also have a typespec: defmodule AuctionHouse.Shared.ExtraGuards do @moduledoc """ Contains additional guards to use in functions. """ defguard is_pos_integer(value) when…
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
0
votes
0 answers

Dialyzer hates my behaviour @callback definition

I've recently started to really leverage Dialyzer in my Elixir work but I'm seeing a strange error that I'm not sure how to correct. I've got a behaviour defined as: defmodule NeatCo.Engine.ConnectionBehaviour do @callback connect(binary,…
jaydel
  • 14,389
  • 14
  • 62
  • 98
0
votes
1 answer

How to override a function or variable type in Elixir and Dialyzer?

I'm using Elixir and I'm getting a Dialyzer (via Dialyxir) error that says The pattern variableVdate can never match, because previous clauses completely cover the type {:error, :badarg}. Here is the code date =…
Jesse Shieh
  • 4,660
  • 5
  • 34
  • 49
0
votes
2 answers

Dialyzer not detecting obvious type error in parametrized type

I'm trying to understand how the dialyzer works with polymorphic/parametrized types. I understand that it is optimistic and will succeed if there is any path through the code that does not cause a crash; what I don't understand is how to use type…
0
votes
1 answer

Dialyzer emits Type specification is a subtype of the success typing for multiple functions with same name

I have the following two functions and I am receiving this dialyzer warning on them: "Type specification 'Elixir.MyModule':calculate(arg1::'Elixir.String':t(),arg2::'Elixir.CustomType':t(),arg3::'Elixir.String':t()) -> 'ok' | 'error';…
Parth Shah
  • 2,060
  • 1
  • 23
  • 34
0
votes
1 answer

Different between throw and catch in handing exception Erlang

I have a simple code like below to test how Erlang handling exceptions. The **** reference for throw and catch. -module(exception). -export([sum/2]). -export([is_odd/1]). sum(A, B) -> case is_odd(A) of odd -> 2*A+B; Result -> …
tandathuynh148
  • 190
  • 5
  • 15
0
votes
1 answer

"spec has wrong arity" seen when using guard clause for Elixir spec definition

Here is the code I am trying to add a spec to. @spec failure(term) :: error(term) @spec failure(reason) :: error(reason) when reason: term defmacro failure(reason) do quote do {:error, unquote(reason)} end end The first spec definition…
Peter Saxton
  • 4,466
  • 5
  • 33
  • 51
0
votes
1 answer

Dialyzer Errors call to missing or unexported function gen_server:call/4

stop_link(UserDefined) -> gen_server:call({local, UserDefined}, terminate, [], []), ok I am using dialyzer to fix warning in erlang code, I came across this mistake which reads missing or unexported function gen_server:call/4. I am not able to…
Raaz444
  • 85
  • 1
  • 7
0
votes
1 answer

Elixir typespec for fixed byte length bitstring - Dialyzer not happy

I'm trying to create a typespec that represents a fixed length framed binary packet. Therefore using a bitstring of fixed N bytes (say 25 for example) seemed like the right idea. The Elixir typespec docs stated the following: …
0
votes
1 answer

Dialyxir error order_by doesnt return Ecto.Query.t

I have this method @spec modify_query(Ecto.Query.t) :: Ecto.Query.t def modify_query(query) do # modifies a Ecto.Query.t end Then I chain that method with a query: Item |> where([active: true]) |> order_by([desc: :start]) |> modify_query The…
lapinkoira
  • 8,320
  • 9
  • 51
  • 94
0
votes
1 answer

Custom Exceptions and type specs

In elixir you can define a custom exception like this: defmodule AppWeb.CustomError do defexception message: "some custom server error", plug_status: 500 end But this is not an Elixir.Exception anymore So if you use it with a third party library…
lapinkoira
  • 8,320
  • 9
  • 51
  • 94
0
votes
1 answer

Dialyzer error on deleting a field from record

I am trying to perform a mnesia table transform for purposes of a schema upgrade. In my new schema, I have deleted one field from my previous definition of the record. The rest of the schema remains unchanged. Here is some code- XformFun =…
Yashesh
  • 91
  • 8
0
votes
1 answer

Dialyzer treats correct .plt file as invalid when it used for analysis

I've built .plt file for ejabberd and standard libraries with the following command: $ dialyzer --build_plt --apps kernel stdlib erts mnesia eunit -o ./dialyzer/ejabberd.plt /path/to/ejabberd/repository/ebin/*.beam The manual check of generated…
citxx
  • 2,525
  • 17
  • 40
0
votes
1 answer

Emulating Interfaces using Behaviours with Dialyzer in Erlang

I want a Java interface equivalent in Erlang. How can I provide a -spec contract for the dialyzer that will allow me to get the as close as possible to functionality provided in Java? Lets say I want something equivalent to this: //Filename:…
Eric des Courtis
  • 5,135
  • 6
  • 24
  • 37
0
votes
1 answer

How do Erlang type specs get preprocessed

I am trying to extend the Erlang Mixer Library (https://github.com/opscode/mixer) to pass the "-spec()." lines for the functions that it is adding to a module. However I am unclear on how erlc places specs into the core erlang code. I started with a…
Zachary K
  • 3,205
  • 1
  • 29
  • 36