Suppress dialyzer error from library

Hey all!

I’m receiving this dialyzer error from a library and I’m not sure how to suppress it on my end.

lib/core/distributed_registry.ex:17:callback_type_mismatch
Type mismatch for @callback init/1 in Horde.Registry behaviour.

Expected type:
{:ok, Keyword.t()}

Actual type:

  :ignore
  | {:ok,
     {%{:intensity => _, :period => _, :strategy => _}, [any()]}
     | %{
         :delta_crdt_options => %{:max_sync_size => _, :shutdown => _, :sync_interval => _},
         :distribution_strategy => _,
         :keys => _,
         :listeners => _,
         :members => _,
         :meta => _
       }}
  | {:stop, {:bad_return, {atom(), :init, _}}}


________________________________________________________________________________
done (warnings were emitted)
Halting VM with exit status 2

Thanks in advance!

Crossreferencing https://github.com/derekkraan/horde/issues/181 here for other readers.

We use Horde.Registry and have this same issue, ended up adding a .dialyzer_ignore.exs containing:

[
  {"path/from/your/error/message", :callback_type_mismatch, line_number_from_message}
]
1 Like

Awesome! Thank you!

I ended up putting this at the top of my registry.

@dialyzer { :nowarn_function, init: 1 }
1 Like

In similar cases @dialyzer { :nowarn doesn’t help much - indeed it does suppress the warning, except any function that uses that function will produce the warning instead. This means either i close my eyes on a few dozen of such warnings across the project or mark every single use with nowarn bandaid, making dyalyzer essentially half-useless. Fixing a library would be the solution, but could be not possible for various reasons

There’s only so much you can do if you don’t control the code. In this case a fix has been merged but not released.

1 Like