<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 28, 2014 at 5:56 PM, PAILLEAU Eric <span dir="ltr"><<a href="mailto:eric.pailleau@wanadoo.fr" target="_blank">eric.pailleau@wanadoo.fr</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
please considere below minimal module :<br>
---8<-------------------------<u></u>---------------------------<br>
-module(test).<br>
<br>
-export([test/0]).<br>
<br>
-record(test, { bool   = 'true' :: boolean()} ).<br>
<br>
test() -> test(#test{}).<br>
<br>
test(R) -> case R#test.bool of<br>
                true  -> ok ;<br>
                false -> ok<br>
           end.<br>
---8<-------------------------<u></u>---------------------------<br>
dialyzer raise an error :<br>
<br>
test.erl:11: The pattern 'false' can never match the type 'true'.<br>
<br>
Looks like dialyzer considere #test.bool to be of type 'true' while it is of type boolean() and default value to 'true'.<br>
<br>
Documentation says :<br>
"In the presence of initial values for fields, the type must be declared after the initialization as in the following:<br>
<br>
  -record(rec, {field1 = [] :: Type1, field2, field3 = 42 :: Type3}).<br>
<br>
Naturally, the initial values for fields should be compatible with (i.e. a member of) the corresponding types. "<br>
<br>
<br>
A bug, isn't it ?<br></blockquote><div><br></div><div>I don't think it's a bug since the only way test/1 can be called is via test/0, and the latter passes a #test{} record instance containing only default values. In this case, the default value of the bool field is true, so dialyzer is correct that false can never match.</div>
<div><br></div><div>--steve<br></div></div></div></div>