kanishka
Learning resources about dialyzer?
I am trying to build up my instincts for what errors dialyzer catches and what errors it doesn’t catch. Are there existing articles or videos that dive deep into Dialyzer and typespecs from a user perspective? I am hoping to avoid articles that go into the implementation of dialyzer.
Most Liked
BartOtten
If I recall correctly this video did help me a lot. It helps you think like Dialyzer which makes it easier to understand why it (does not) reports an error: https://youtu.be/Nxsw1jRE2A4
garazdawi
While it in some parts is a bit heavy to read, the original paper on success typing contains a lot of information and if you understand what success typing is (and what it is not), then deciphering the error messages becomes easier.
BartOtten
Dialyzer is never wrong. When it knows an spec mismatch will happen in any case, it will report an error. If it might happen, it won’t as the conditions in which the function returns a non matching type might never occur. After all: you as a developer might call the function only in a way that makes it matching.
Example
@ spec foo(arg :: integer) :: :ok
def foo(arg) when is_integer(arg) do
case arg do
1 -> :ok
_other -> :error
end
end
You might think Dialyzer should/would warn that :error is not in the spec.
However, Dialyzer thinks different:
Maybe this function is only ever called with foo(1); then there is no issues at all as indeed it only will return :ok. I will not raise an issue.
There are flags to tune this behavior but their usage might cause other ‘issues’ so those are false by default.
Popular in Chat/Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








