chrisdel101
ElixirLS Suppress warnings: where to put @dialyzer command?
After reading Dialyzer: suppress warning on a specific function, I think I know what I need but I don’t know where to put it.
I get a warning that is just wrong. It’s on code that runs and is often accessed, i.e. a major piece of the codebase. I have this warning in a few other places too where it should not be, and nothing I do gets rid if of it.
The pattern can never match the type.
Pattern:
{:error, _error}
Type:
{:ok, <<_::296>> | map()} | {:error, map(), number()}
I think I can use this to silence it, but where does it go?
Should be maybe @dialyzer {:Wno_match, handle_event/3}@dialyzer {:Wno_match, handle_event: 3}
I put it at the top of the module and I get the error: undefined variable "handle_event"invalid value for @dialyzer attribute: {:Wno_match, [handle_event: 3]} I guess I’m using to wrong also, hence the invalid value, but the docs are quite dense.
This is just the default LiveView handle_event.
PS: this the demo line for how to use this, but it makes no sense to me.
defmodule Myapp.Repo do
use Ecto.Repo, otp_app: :myapp
@dialyzer {:nowarn_function, rollback: 1}
end
Let’s start with where in the file this goes. Then we’ll handle the invalid value issue which has sprung up as I posted this.
Most Liked
chrisdel101
I got it to work. The @dializer macro (it is a marco right?) goes at the top the module in question. Then you must put in the correct erlang disable warning option.
I had difficulty understanding the erlang docs, but the info was there the entire time. The warning options are these. I needed no_match
warn_option() =
error_handling | no_behaviours | no_contracts | no_fail_call |
no_fun_app | no_improper_lists | no_match | no_missing_calls |
no_opaque | no_return | no_undefined_callbacks |
no_underspecs | no_unknown | no_unused | underspecs |
unknown | unmatched_returns | overspecs | specdiffs |
extra_return | no_extra_return | missing_return |
no_missing_return
So I put this at the top of my file and the warnings are now ignored.
defmodule MyApp.UserLive.Index do
@dialyzer {:nowarn_function, handle_event: 3}
sabiwara
It is actually a module attribute, not a macro ![]()
Like macros, they are also compile-time.
Popular in 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









