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

Polymorphic types for dialyzer in Elixir

Background I have a struct called MyApp.Result that is basically a representation of a Result Monad. This struct aims to be a formal structural representation for operation success and error: defmodule MyApp.Result do @enforce_keys [:type] …
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
2
votes
2 answers

How can I get Dialyzer to accept a call to a function that intentionally throws?

I have a function that intentionally throws when its first argument is the atom throw. A simplified version of this code is: -module(sample). -export([main/1, throw_or_ok/1]). main(_Args) -> throw_or_ok(throw). throw_or_ok(Action) -> …
Max Heiber
  • 14,346
  • 12
  • 59
  • 97
2
votes
1 answer

How can I suppress dialyzer warning on comparison between module variable and local static variable?

Dialyzer blames the code trying to match against module variable: defmodule Main do # -> :demo @env Application.get_env(:myproject, :env) def run do case @env do :production -> 1 _ -> 2 end …
ryochin
  • 67
  • 5
2
votes
1 answer

Run of dialyzer after annotation with typer did not show any warnings

In a project with about 6000 lines of Erlang code but no type -spec() annotation yet I tried the following: typer --annotate *.erl The I replaced all *.erl files with the annotated ones and ran dialyzer --src -c *.erl I expected to get lots of…
Peer Stritzinger
  • 8,232
  • 2
  • 30
  • 43
2
votes
1 answer

How to spec a callback with variable number of arguments in Elixir

I have a behaviour that wraps any function. defmodule MyBehaviour do @callback do_run( ? ) :: ? #the ? means I don't know what goes here defmacro __using__(_) do quote location: :keep do @behaviour MyBehaviour def run, do:…
tkowal
  • 9,129
  • 1
  • 27
  • 51
2
votes
1 answer

Ignore dialyzer warning for generated code

I am trying to make my library(https://github.com/CrowdHailer/OK) for working with result tuples play nicely with dialyzer. At them moment there is code that raises a nice error if incorrect data input is given. However dialyzer points out that…
Peter Saxton
  • 4,466
  • 5
  • 33
  • 51
2
votes
1 answer

How do I fix a "will never return since the success typing is [...] and the contract is.." from Dialyzer?

I am using Dialyzer to fix errors in Erlang code. io:format(IoDevice, "[]"); This line produces the following error: The call io:format(IoDevice::pid(),[91 | 93,...]) will never return since the success typing is (atom() | binary() |…
Raaz444
  • 85
  • 1
  • 7
2
votes
1 answer

Why doesn't dialyzer detect this bad type?

Dialyzer behaves rather strangely to me in this case, and I haven't found anything to better understand it. This is not an error: defmodule Blog.UserResolver do @type one_user :: ( {:error, String.t} ) @spec find(%{id: String.t}, any()) ::…
sgrove
  • 1,149
  • 2
  • 11
  • 23
2
votes
0 answers

Can't get dialyzer to work with evm

I have erlang 17.5 installed in /usr/local/lib. evm considers that my "system" install. After installing evm, I downloaded erlang 19.2, and I can switch back and forth between my two versions of erlang using: $ evm system (erlang 17.5) $ evm use…
7stud
  • 46,922
  • 14
  • 101
  • 127
2
votes
1 answer

Ecto changesets and Dialyzer errors

I have an umbrella app. I see the value of Dialyzer and I'm trying to get started with it. I've gotten pretty far but I have an issue around Ecto I cannot solve. This is for a small App in the umbrella that handles Authentication. I can trim it all…
Mark Eric
  • 753
  • 1
  • 7
  • 14
2
votes
2 answers

dialyxir mix task to create PLT exits without error or creating table

I am trying to use dialyxir to run dialyzer analysis on my project through the mix tasks it provides. I have added it to my dependencies and compiled as per the README. When I run the mix dialyxir.plt it reports no error and yet exits without…
Peter Saxton
  • 4,466
  • 5
  • 33
  • 51
2
votes
1 answer

Does type [string()] cover empty list?

When defining a type which will be a list of strings but can also be an empty list, do I have to define both cases like this: -type my_type() :: [string()] | []. or is this enough: -type my_type() :: [string()].
Sergey Ovchinnik
  • 472
  • 4
  • 16
2
votes
1 answer

Understanding dialyzer result

I have the following function: -spec check_connection_header(list()) -> atom(). check_connection_header([{<<"Connection">>, <<"close">>}|_]) -> close; check_connection_header([{<<"Connection">>, <<"Close">>}|_]) -> …
Limmen
  • 1,407
  • 11
  • 17
2
votes
1 answer

Dialyzer error for struct

Here's a minimum broken example in Elixir 1.3: defmodule Foo do @type t :: %__MODULE__{x: non_neg_integer} defstruct x: 0 @spec test(t) :: t def test(%__MODULE__{} = foo), do: test2(foo) @spec test2(t) :: t defp test2(%__MODULE__{} =…
knite
  • 6,033
  • 6
  • 38
  • 54
2
votes
1 answer

Elixir, Dialyzer, Types and Subtyping Warnings

I am running Dialyzer with '-Woverspecs' and receive this warning: room_channel.ex:143: Type specification 'Elixir.Backend.RoomChannel': testU(a) -> a when is_subtype(a,#{}) is a subtype of the success typing: 'Elixir.Backend.RoomChannel':testU(_)…
user3264325
  • 237
  • 1
  • 2
  • 9