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

Typespecs for Arc.Ecto.changeset

I am copying Arc.Ecto changeset example https://github.com/stavro/arc_ecto and I am not sure about the typespecs, I am trying with these but doesnt seem to work for dialyzer, it complains on |> cast_attachments(params, [:avatar]) @spec…
lapinkoira
  • 6,688
  • 7
  • 36
  • 74
3
votes
1 answer

Elixir / Erlang Dialyzer : Why behaviour callback's param type should be subtype instead of supertype?

I have a behaviour X and a callback function with parameter type: %{a: any} Module Y implements behaviour X and the callback function in implementing module Y has parameter type: %{a: any, b: any} Dialyzer doesn't like that and…
Ahmad Ferdous
  • 3,161
  • 12
  • 28
3
votes
1 answer

Function arity as a result of default parameters in elixir making dialyzer complain

I have a function with 2 default parameters defp foo(bar, baz, qux \\ "", garply \\ nil) I’ve got two usages, one supplies only the first two parameters, the other all 4. Dialyzer is complaining that Function foo/3 will never be called. I assume…
kolosy
  • 2,859
  • 3
  • 25
  • 47
3
votes
2 answers

Erlang Dialyzer integer ranges

-module(test). -export([f/0, g/0]). -spec f() -> RESULT when RESULT :: 0..12 . -spec g() -> RESULT when RESULT :: 0..13 . f () -> 100 . g () -> 100 . Running dialyzer (and typer) only the function f is caught. dialyzer…
beoliver
  • 5,068
  • 5
  • 29
  • 68
3
votes
1 answer

Why Erlang Dialyzer cannot find type error in the following code?

free_vars_in_dterm({var, V}) -> {var, V}; obviously cannot type check, however, dialyzer says everything is OK. $ dialyzer *erl Checking whether the PLT ~/.dialyzer_plt is up-to-date... yes Proceeding with analysis... done in 0m0.66s done…
kainwen
  • 326
  • 1
  • 11
3
votes
0 answers

The created fun has no local return

Test under Erlang R15B. -spec parse_packet(integer(), binary()) -> list(). parse_packet(16013, <<0:16, _/binary>>) -> []; parse_packet(16013, <>) -> SizePerMount = byte_size(ListBin) div ListNum, (1)Fun = fun(_,…
Yejun Su
  • 2,237
  • 3
  • 25
  • 43
2
votes
1 answer

erlang dialyzer and extended modules

Dialyzer doesn't like calls to functions in the base module. Is there a dialyzer flag to skip this error or am I doing some wrong. Here is a similar code: -module(base). -export(foo/1). foo(X) ->…
cashmere
  • 2,571
  • 1
  • 21
  • 32
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
  • 10,336
  • 4
  • 47
  • 67
2
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,485
  • 12
  • 26
2
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...
  • 685
  • 6
  • 13
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
  • 7,844
  • 2
  • 27
  • 41
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
  • 8,659
  • 1
  • 20
  • 42
2
votes
1 answer

Dialyzer warnings about pattern_match_cov on Gettext module

I started using Dialyzer (dialyxir 1.0.0-rc.6) on my umbrella project based on Phoenix 1.4. When I ran mix dialyzer on it for the first time, I got this warning. apps/my_app/lib/my_app_web/gettext.ex:1:pattern_match_cov The pattern %{} can never…
Tsutomu
  • 4,381
  • 38
  • 62
2
votes
1 answer

Is there a way to make Dialyzer watch code changes?

I'm using dialyxir which appends a dialyzer task to Mix. But it doesn't seem to have any --watch option that would rerun the type checking on file changes. Is there a CLI way to achieve that?
Ivan Gabriele
  • 5,018
  • 3
  • 31
  • 52
2
votes
1 answer

dialyzer fails to recognise elixir functions with error :0:unknown_function

I have elixir 1.7.2 on my computer installed using asdf, both elixir and erlang otp 21. On my project mix file I have added the latest release candidate of dialyzer as instructed on dialyzer github {:dialyxir, "~> 1.0.0-rc.3", only: [:dev],…
Sigu Magwa
  • 516
  • 5
  • 18