yawaramin

yawaramin

Dialyzer: suppress warning on a specific function

In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function:

-dialyzer({no_return, g/0}).

If I’m understanding correctly, this should turn off the ‘function has no local return’ warning.

Is there a way to express this in Elixir? The following is giving me an ArithmeticError:

@dialyzer {:no_return, :g/0}

Marked As Solved

idi527

idi527

Right!

defmodule Myapp.Repo do
  use Ecto.Repo, otp_app: :myapp
  @dialyzer {:nowarn_function, rollback: 1}
end

from Phoenix Dialyxir Quickstart · jeremyjh/dialyxir Wiki · GitHub

So -dialyzer({no_return, g/0}). would probably become

@dialyzer {:no_return, g: 0}
11
Post #3

Also Liked

NobbZ

NobbZ

If I recall correctly, its @dialyzer {:no_return, {:g, 0}}.

acco

acco

For posterity: you can also disable warnings for functions for third-party deps/modules:

@dialyzer {:nowarn_function, &MyXQL.rollback/2}
# somewhere later...
    {:error, res} =
      MyXQL.transaction(pid, fn conn ->
        MyXQL.query!(conn, statement, params)
        MyXQL.rollback(conn, :rolled_back)
      end)
scottming

scottming

I think this way is better, some function that calling the g/0 function also will be disabled

  @dialyzer {:noreturn_function, g: 0}

Last Post!

maltoe

maltoe

Just in case somebody else keeps looping back into this thread looking for possible values for @dialyzer: Here’s the list.

https://github.com/elixir-lang/elixir/blob/1b0dff7e6a667b0aba73d2ee7982d854d80bee90/lib/elixir/lib/module.ex#L2352-L2363

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31586 112
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
saif
Hello everyone, Long time lurker first time poster here. I’ve recently begun working on Elixir full-time again! :raised_hands: It’s been...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement