[erlang-bugs] Typer Bug ?
P Arun Babu
arun.babu@REDACTED
Fri Mar 23 09:19:44 CET 2012
Hi,
typer seems to be producing wrong spec for the below code.
Also, dialyzer with "-Wunmatched_returns -Werror_handling -Wbehaviours -Wunderspecs -Woverspecs" shows no warnings.
I am wondering ... is this a bug ?
Thanks,
-ARUN
-------------------------------------------------------------------------------
%% File: "test.erl"
%% ----------------
-spec is_valid(_) -> boolean().
-spec start(_,_) -> {['abs_n1_minus_n2_gt_5' | 'both_are_invalid' |
'n1_is_invalid' | 'n2_is_invalid' | 'this_could_be_a_bug'],_,'not_ok' |
'ok'}.
-module(test).
-export([start/2]).
is_valid (N) ->
N > 10.
start ( N1 , N2) ->
Is_valid_N1 = is_valid (N1),
Is_valid_N2 = is_valid (N2),
case {Is_valid_N1, Is_valid_N2} of
{ false, true } ->
{ [n1_is_invalid], N2 , ok};
{ true, false } ->
{ [n2_is_invalid], N1, ok};
{ false, false } ->
{ [
n1_is_invalid,
n2_is_invalid,
both_are_invalid,
this_could_be_a_bug
],
invalid, not_ok };
{ true, true } ->
case N1 < N2 of
true -> Minimum = N1;
false -> Minimum = N2
end,
case abs(N1- N2) > 5.0 of
false -> { [], Minimum, ok };
true -> { [abs_n1_minus_n2_gt_5], Minimum, ok }
end
end.
-------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120323/4b4741d2/attachment.htm>
More information about the erlang-bugs
mailing list