[erlang-questions] Erlang 17 issue with dialyzer and nowarn_deprecated_type

Shayan Pooya <>
Wed Apr 16 16:14:05 CEST 2014


Thanks Hans,

I worked around this issue in the code to let it work on both Erl 17 and
the previous versions:
https://github.com/discoproject/disco/commit/b4e1d4d723e0bd8ae1a61827d62c5643e8aa9e5d

In the near future, I am going to use the method deployed by meck to remove
this nowarn option:
-ifdef(namespaced_types).
-type disco_dict() :: dict:dict().
-type disco_gbtree() :: gb_trees:tree().
-type disco_gbtree(K, V) :: gb_trees:tree(K, V).
-type disco_gbset() :: gb_sets:set().
-type disco_gbset(K) :: gb_sets:set(K).
-type disco_queue() :: queue:queue().
-else.
-type disco_dict() :: dict().
-type disco_gbtree() :: gb_tree().
-type disco_gbtree(_,_) :: gb_tree().
-type disco_gbset() :: gb_set().
-type disco_gbset(_) :: gb_set().
-type disco_queue() :: queue().
-endif.




On Wed, Apr 16, 2014 at 5:49 AM, Hans Bolinder
<>wrote:

>  Hi,
>
> [Shayan Pooya:]
>
> > In order to make Disco compile with Erlang 17 without warnings, I
> > added nowarn_deprecated_type to silence the warnings. However, after
> > doing so, dialyzer fails with the following error:
> >
> > ddfs_master.erl:345: Attempt to test for inequality between a term of
> type 'false' and a term of opaque type 'false' | gb_set()
>
> This is a bug. There will be a fix in 17.1. You can
> try the patch below, or run Dialyzer with the "-Wno_opaque" option.
>
> Best regards,
>
> Hans Bolinder, Erlang/OTP team, Ericsson
>
> diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl
> index 47b8dc7..6065b79 100644
> --- a/lib/hipe/cerl/erl_types.erl
> +++ b/lib/hipe/cerl/erl_types.erl
> @@ -2985,16 +2985,19 @@ inf_union(U1, U2, Opaques) ->
>          List = [A,B,F,I,L,N,T,M,Map],
>          inf_union_collect(List, Opaque, InfFun, [], [])
>      end,
> -  O1 = OpaqueFun(U1, U2, fun(E, Opaque) -> t_inf(Opaque, E, Opaques) end),
> -  O2 = OpaqueFun(U2, U1, fun(E, Opaque) -> t_inf(E, Opaque, Opaques) end),
> -  Union = inf_union(U1, U2, 0, [], Opaques),
> -  t_sup([O1, O2, Union]).
> +  {O1, ThrowList1} =
> +    OpaqueFun(U1, U2, fun(E, Opaque) -> t_inf(Opaque, E, Opaques) end),
> +  {O2, ThrowList2}
> +    = OpaqueFun(U2, U1, fun(E, Opaque) -> t_inf(E, Opaque, Opaques) end),
> +  {Union, ThrowList3} = inf_union(U1, U2, 0, [], [], Opaques),
> +  ThrowList = lists:merge3(ThrowList1, ThrowList2, ThrowList3),
> +  case t_sup([O1, O2, Union]) of
> +    ?none when ThrowList =/= [] -> throw(hd(ThrowList));
> +    Sup -> Sup
> +  end.
>
>  inf_union_collect([], _Opaque, _InfFun, InfList, ThrowList) ->
> -  case t_sup(InfList) of
> -    ?none when ThrowList =/= [] -> throw(hd(lists:flatten(ThrowList)));
> -    Sup -> Sup
> -  end;
> +  {t_sup(InfList), lists:usort(ThrowList)};
>  inf_union_collect([?none|L], Opaque, InfFun, InfList, ThrowList) ->
>    inf_union_collect(L, Opaque, InfFun, [?none|InfList], ThrowList);
>  inf_union_collect([E|L], Opaque, InfFun, InfList, ThrowList) ->
> @@ -3005,19 +3008,21 @@ inf_union_collect([E|L], Opaque, InfFun, InfList,
> ThrowList) ->
>        inf_union_collect(L, Opaque, InfFun, InfList, [N|ThrowList])
>    end.
>
> -inf_union([?none|Left1], [?none|Left2], N, Acc, Opaques) ->
> -  inf_union(Left1, Left2, N, [?none|Acc], Opaques);
> -inf_union([T1|Left1], [T2|Left2], N, Acc, Opaques) ->
> -  case t_inf(T1, T2, Opaques) of
> -    ?none -> inf_union(Left1, Left2, N, [?none|Acc], Opaques);
> -    T     -> inf_union(Left1, Left2, N+1, [T|Acc], Opaques)
> +inf_union([?none|Left1], [?none|Left2], N, Acc, ThrowList, Opaques) ->
> +  inf_union(Left1, Left2, N, [?none|Acc], ThrowList, Opaques);
> +inf_union([T1|Left1], [T2|Left2], N, Acc, ThrowList, Opaques) ->
> +  try t_inf(T1, T2, Opaques) of
> +    ?none -> inf_union(Left1, Left2, N, [?none|Acc], ThrowList, Opaques);
> +    T     -> inf_union(Left1, Left2, N+1, [T|Acc], ThrowList, Opaques)
> +  catch throw:N when is_integer(N) ->
> +      inf_union(Left1, Left2, N, [?none|Acc], [N|ThrowList], Opaques)
>    end;
> -inf_union([], [], N, Acc, _Opaques) ->
> -  if N =:= 0 -> ?none;
> +inf_union([], [], N, Acc, ThrowList, _Opaques) ->
> +  if N =:= 0 -> {?none, ThrowList};
>       N =:= 1 ->
>        [Type] = [T || T <- Acc, T =/= ?none],
> -      Type;
> -     N >= 2  -> ?union(lists:reverse(Acc))
> +      {Type, ThrowList};
> +     N >= 2  -> {?union(lists:reverse(Acc)), ThrowList}
>    end.
>
>  inf_bitstr(U1, B1, U2, B2) ->
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140416/f42c99bc/attachment.html>


More information about the erlang-questions mailing list