[erlang-questions] Lack of warning for overlapping clauses with

Tony Rogvall <>
Tue Jul 20 13:37:45 CEST 2010

I also think that case analysis could be improved, but I guess you are aware of that
the general problem is a hard nut. Just look at this very academic example ;-)

f(1,1), f(1,2), f(1,3) are actually overlaps, can you see why? ;-) 
If there was a theorem prover built in to the compiler it may prove that, and warn about the overlap.
But how long time do you want for the compiler to complete?

-define(p(Pi,Hj), ((P =:= (Pi)) and (H =:= (Hj)))).
-define(pi(Pi), (?p(Pi,0) or ?p(Pi,1) or ?p(Pi,2))).
	(not (?p(0,Hi) and ?p(1,Hi)) and
	 not (?p(0,Hi) and ?p(2,Hi)) and
	 not (?p(0,Hi) and ?p(3,Hi)) and
	 not (?p(1,Hi) and ?p(2,Hi)) and
	 not (?p(1,Hi) and ?p(3,Hi)) and
	 not (?p(2,Hi) and ?p(3,Hi)))).

  when P>=0, P =< 3, H >=0, H =< 2,
       not (?pi(0) and ?pi(1) and ?pi(2) and ?pi(3) and
	    ?hi(0) and ?hi(1) and ?hi(2)) ->
f(1,1) -> 2;
f(1,2) -> 3;
f(1,3) -> 4;
f(_P,_H) ->


On 20 jul 2010, at 11.30, Torben Hoffmann wrote:

> On Tue, Jul 20, 2010 at 11:03, Kostis Sagonas <> wrote:
>> Torben Hoffmann wrote:
>>> I am afraid that Bernard is right - there is no difference... neither erlc
>>> or Dialyzer picks it up.
>>> I would like to hear from the OTP team and/or the Dialyzer team to
>>> understand what is cooking here.
>> There is not much to say here, nor anything fishy is cooking. It's just
>> that or's/orelse's in guards are not so common in their proper treatment is
>> not so easy.
> That was my fear/expectation - as Joe once said "It is easy to get the
> typing right in 98% of the cases and then you'll have to fight hard to get
> the last 2%"
>> Neither erlc not dialyzer ever promised that it will generate all possible
>> warnings. In fact, as far as dialyzer is concerned the only thing that was
>> promised is that it will not generate a false warning.
> That is fair enough - I was just surprised that this one got through, but
> the handling of or in a guard is going to create some nasty scenarios.
>> Now, having written that, thanks for your mail because it gives us a
>> concrete test case to improve erlc and/or dialyzer.
> Great - this reinforces my belief in sharing experiences!
> Cheers,
> Torben
>> Kostis
> -- 
> http://www.linkedin.com/in/torbenhoffmann

More information about the erlang-questions mailing list