# Unmatched Dialyzer Warnings

In an effort to make Dialyzer unmatched checks more palatable I started wrapping Logger functions

E.g.

``````def match_all(f, a, b), do:
_ = f.(a, b)

def info(chardata_or_fn, metadata \\ []), do:
``````

which nice removes the warnings.

However if I don’t use anonymous functions but plain function calls, the warnings remain.

E.g.

``````def info(chardata_or_fn, metadata \\ []), do:
``````

Any idea why?

1 Like

Hmm, I cannot replicate that in the shell. Do you have a complete compilable example or a git demonstrating the behaviour?

1 Like

I think it is because when you make the literal function call then dialyzer knows which function you are actually using and do the check. When you wrap it you are creating a fun which you then pass as argument into another function which calls it. Now dialyzer can’t keep track of what you are calling so it can’t check.

Why are you do you have the match `_ = Logger.info(chardata_or_fn, metadata)` and not just define it as

``````def info(chardata_or_fn, metadata \\ []), do:
``````

Same with `match_all`. The match serves no purpose. The compiler will optimise it away so it won’t cost anything, but again it serves no purpose.

1 Like

I’ll post up an example later - thanks for taking interest : )

The purpose is purely to avoid Dialyzer giving warnings about unmatched returns.

Your example still results in a Dialyzer warning.

Thanks for the explanation though.

So… basically I have just bamboozled Dialyzer : ) so that it doesn’t give the unmatched warning…

Which is what I was trying to achieve - on the one hand.

On the other, it’s a little troubling - i.e. that Dialyzer won’t check similar anonymous functions - which in general - I would really like it to check…

Dialyzer can check the anon function itself but has great difficulty in checking functions that are called with an anon function. Maybe type specing such a function could help? I don’t know as I am not really a dialyzer fan and seldom seriously use it. Except to tag some functions as `no_return()` to keep dialyzer quiet.

1 Like