<div dir="ltr"><div>Hi all, </div><div><br></div><div>I was just struck by a bug in my code due to wrong ordering of clauses. Given a function f/1 which could be simplified to something like this: </div><div><br></div><div>f([a, B]) -></div><div>    B;</div><div>f([a, b]) -></div><div>    will_never_happen.</div><div><br></div><div>The problem is that the clause f([a, b]) is never taken simply because it is fully covered by the first clause which matches all values for the second element in the list. If I had put the second clause before the more general clause it would have worked the way I thought it should. </div><div><br></div><div>I'm curious though. Why did the compiler not spot the problem in the code for f/1 when it can obviously spot the problem in a, to me at least, similar function f/2 seen below?:</div><div><br></div><div>f(a, B) -></div><div>    B;</div><div>f(a, b) -></div><div>    will_never_happen.</div><div><br></div><div>In this example, (f/2), I get a compilation error with a very good and detailed description of what the problem is, but in the first case (f/1) the compiler does not see the problem (or cannot?) with the covering clause. <br><br>Is this some edge case where the compiler has just stopped caring and I must use dialyser to spot the problem at an earlier stage than at runtime?<br><br>Stefan</div><div><br></div><div><br></div><div>p.s. funny thing is that if I use a tuple instead of a list to create f/1 in the same way the compiler is once again able to spot the problem, but not with a list as argument. </div></div>