Compilation Error - "warning: "else" clauses will never match because all patterns in "with" will always match"

$ iex -S mix
Erlang/OTP 23 [erts-11.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Compiling 3 files (.ex)
warning: "else" clauses will never match because all patterns in "with" will always match

WalletValue.ex:1 -
defmodule WalletValue do

What’s more, this module does not employ any “with” statements so how do I resolve this warning?

It is impossible to debug this without more info…

You can try to search for with inside your code and show relevant part.

Hmmm . . . the particular module referenced in the error message doesn’t use any “with” statements so are you suggesting the entire codebase be searched for such a statement?

If You are on unix, You can try…

find lib -type f -exec grep -H with {} \;

but the name seems wrong, as it is camelcase, but files are usually underscore. And the location is strange too, as it is not in a context.

1 Like

Error messages pointing at line 1 are sometimes a symptom of a macro that’s generating code that triggers a warning.


Interesting. How do I discover out which macro is responsible?

Can you show the module code?

Sorry, no. Thing is I didn’t create any macros in any modules for this project. Where should I look for the potential offending macro, then?

Without showing any code it won’t be easy for people to help you…

Maybe could you remove the WalletValue module completely from the project to see if you still gets this error? Once you find the culprit module (the one that the removal removes also the warning) I guess you would be closer to a fix.

Good luck.


Those that you have not created by yourself.

Look out for calls to use/2, import/2 and require/2. For imports and requires you also need to check the calls into the required/imported modules whether they are macros or function calls.

It would really be much easier for us to debug with you, if you were stripping the offending module as much as possible and then create a minimal project at GitHub that show the problem.


Thanks for the suggestion. It seems that the issue is with a library the module is using since removing it clears the warnings.