<div dir="ltr">This is a part of the compiler I'm not really an expert on, I would defer to Robert or Björn in this case.<div>However, I believe it is the "variable split" that happens in match compilation in kernel that is the cause of this. First I believed it was just the order in which the compiler chooses the values to match (left to right) but i don't think it's the case here (though i've seen that too).</div><div><br></div><div>Ideally, we shouldn't traverse the clauses left to right but instead weight and sniff out the optimal matching path in the tree but that's a debate for another time perhaps (and a fun one).</div><div><br></div><div>One could also question why the kernel should emit this warning and not the linter. I guess pragmatism.</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-04-08 9:52 GMT+02:00 Anthony Ramine <span dir="ltr"><<a href="mailto:n.oxyde@gmail.com" target="_blank">n.oxyde@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Le 8 avr. 2015 à 08:46, Erik Søe Sørensen <<a href="mailto:eriksoe@gmail.com">eriksoe@gmail.com</a>> a écrit :<br>
<br>
> It would of course make sense to have the compiler warn in this case.<br>
> However - if my understanding of the compiler implementation is correct - matching of binaries is handled specially, and apparently in such a manner that it doesn't realise that the two binary patterns are identical.<br>
> /Erik<br>
<br>
</span>That would be a reasonable explanation, but unfortunately it's not the case. If you compile that module to BEAM assembly, you can see very that the two patterns are indeed merged together, there is only one occurrence of "user_auth" in it.<br>
<br>
{function, authenticate_nouns, 1, 2}.<br>
  {label,1}.<br>
    {line,[{location,"wat_clauses.erl",3}]}.<br>
    {func_info,{atom,wat_clauses},{atom,authenticate_nouns},1}.<br>
  {label,2}.<br>
    {test,is_nonempty_list,{f,4},[{x,0}]}.<br>
    {get_list,{x,0},{x,1},{x,2}}.<br>
    {test,is_tuple,{f,4},[{x,1}]}.<br>
    {test,test_arity,{f,4},[{x,1},2]}.<br>
    {get_tuple_element,{x,1},0,{x,3}}.<br>
    {get_tuple_element,{x,1},1,{x,4}}.<br>
    {test,bs_start_match2,{f,4},5,[{x,3},0],{x,5}}.<br>
    {test,bs_match_string,{f,4},[{x,5},72,{string,"user_auth"}]}.<br>
    {test,bs_test_tail2,{f,4},[{x,5},0]}.<br>
    {test,is_nil,{f,3},[{x,2}]}.<br>
    {move,{atom,true},{x,0}}.<br>
    return.<br>
  {label,3}.<br>
    {test,is_nonempty_list,{f,4},[{x,4}]}.<br>
    {get_list,{x,4},{x,6},{x,7}}.<br>
    {test,bs_start_match2,{f,4},8,[{x,6},0],{x,8}}.<br>
    {test,bs_match_string,{f,4},[{x,8},64,{string,"recovery"}]}.<br>
    {test,bs_test_tail2,{f,4},[{x,8},0]}.<br>
    {test,is_nil,{f,4},[{x,7}]}.<br>
    {test,is_nil,{f,4},[{x,2}]}.<br>
    {move,{atom,hi},{x,0}}.<br>
    return.<br>
  {label,4}.<br>
    {move,{atom,false},{x,0}}.<br>
    return.<br>
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>