I’m seeing this warning at compile time and while I know what the issue is, the warning message doesn’t give me much to go on.
My situation (vastly simplified) is that I’ve got a module that implements various versions of a function. Let’s call that function parse_line/3. I also have some other versions of that function in a module (to be shared across different modules). Here’s the main module:
defmodule UseThisModule do defmacro __using__(_opts) do quote do def parse_line("a", b, c), do: ... def parse_line(a, "b", c), do: ... end end end
And here is the module that uses it:
defmodule NeedsThatModule do use UseThisModule def parse_lin("a", 234, _), do: ... end
It’s pretty easy to see that the parse_line in NeedsThatModule is going to never be found because of the first one in UseThisModule. I understand that and I know how to deal with it. My problem is that in UseThisModule there are 10+ versions of
parse_line/3 and in NeatModule there are 15+. The warning says, as expected:
“warning: this clause cannot match because a previous clause at line 4 always matches
In my example, line 2 is where the “use” expression is found. Conceptually, I know what is going on, but given the sheer number of versions of the
parse_line/3 function, it’s extremely painful to identify WHICH of the versions in UseThisModule is the one to check on.
I guess I’m looking for strategies to simplify this situation, or even better, a way to get more details in the warning.
At any rate, if this is unclear, let me know and I’ll try again