How to avoid a “can never match” error from Dialyzer in a `with` statement that has a match all `else`?

Dialyzer is very user unfriendly. Nevertheless, if it reports an error it means that based on the various type specification you have annotated your functions with, accordingly it is seeing a contradiction with your actual usage.

When Dialyzer is complaining about {'error',<<_:64,_:_*8>>}, it means that Argon2.check_pass has some contradictory type specifications to it, either itself, or either potentially something deeper down. Dialyzer is not very friendly in its ability to point you out exactly where and why contradictions are happening.

As I do not have full access to your code, in order to resolve the issue, at most I can point you out to following a few steps:

  1. If Argon2.check_pass has an explicit @spec annotation, then comment that out and see if Dialyzer still complains.

  2. If the complaint is gone, then modify various parts of @spec annotation with any until the problem is gone for identification purposes. Accordingly the issue will resolve there or either you need to dig deeper in other functions that Argon2.check_pass relies on that may be the cause of the issue.

  3. In the case that 1. fails, then copy paste the function defined Argon2.check_pass as a private function: tmp_check_pass and see how that changes the issue.

4.If need be, you may need to introduce more of these tmp_... functions that Argon2.check_pass is relying on in order to isolate the root cause of the complaint. Before doing that, first try commenting out all the @spec annotations of any of the supporting functions that Argon2.check_pass leverages and apply point 1 accordingly.

Eventually, you will arrive at a particular point in your code, where according to the specifications that you have provided to Dialyzer, that some usage of your code violates it being: of type {'error',<<_:64,_:_*8>>}

The key thought here is to try to isolate the root cause of the complaint, which Dialyzer regretfully is not too precise at pointing out for you from time to time.