chrisdel101

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?
@dialyzer {:Wno_match, handle_event/3} Should be maybe @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

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

sabiwara

Elixir Core Team

It is actually a module attribute, not a macro :slight_smile:
Like macros, they are also compile-time.

Where Next?

Popular in Questions Top

New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: &lt;h1&gt;Create Post&lt;/h1&gt; &lt;%= ...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

Other popular topics Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29603 241
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement