[erlang-bugs] Dialyzer chokes on remote types in t_contains_opaque()

Hans Bolinder hans.bolinder@REDACTED
Fri May 9 14:53:12 CEST 2014


Hi,

> Using Erlang 17.0, I get Dialyzer errors like the following:
> {function_clause,[{erl_types,t_contains_opaque,
>                              [{c,remote,[{remote,ssl,sslsocket,[]}],unknown}, ...}

Thanks for reporting this.

It seems to an old bug with a new symptom since 17.0.

Best regards,

Hans Bolinder, Erlang/OTP team, Ericsson

A diff against 66e9c3d:

diff --git a/lib/hipe/cerl/erl_types.erl b/lib/hipe/cerl/erl_types.erl
index 6065b79..06c0d10 100644
--- a/lib/hipe/cerl/erl_types.erl
+++ b/lib/hipe/cerl/erl_types.erl
@@ -209,6 +209,7 @@
      type_is_defined/4,
      record_field_diffs_to_string/2,
      subst_all_vars_to_any/1,
+         subst_all_remote/2,
      lift_list_to_pos_empty/1,
          is_opaque_type/2,
      is_erl_type/1,
@@ -3161,6 +3162,18 @@ t_subst_aux(?union(List), VarMap) ->
 t_subst_aux(T, _VarMap) ->
   T.

+-spec subst_all_remote(erl_type(), erl_type()) -> erl_type().
+
+subst_all_remote(Type0, Substitute) ->
+  Map =
+    fun(Type) ->
+        case erl_types:t_is_remote(Type) of
+          true -> Substitute;
+          false -> Type
+        end
+    end,
+  erl_types:t_map(Map, Type0).
+
 %%-----------------------------------------------------------------------------
 %% Unification
 %%
@@ -4474,7 +4487,7 @@ get_mod_record([{FieldName, DeclType}|Left1],
            [{FieldName, ModType}|Left2], Acc) ->
   ModTypeNoVars = subst_all_vars_to_any(ModType),
   case
-    t_is_remote(ModTypeNoVars) orelse t_is_subtype(ModTypeNoVars, DeclType)
+    contains_remote(ModTypeNoVars) orelse t_is_subtype(ModTypeNoVars, DeclType)
   of
     false -> {error, FieldName};
     true -> get_mod_record(Left1, Left2, [{FieldName, ModType}|Acc])
@@ -4488,6 +4501,10 @@ get_mod_record(DeclFields, [], Acc) ->
 get_mod_record(_, [{FieldName2, _ModType}|_], _Acc) ->
   {error, FieldName2}.

+contains_remote(Type) ->
+  TypeNoRemote = subst_all_remote(Type, t_none()),
+  not t_is_equal(Type, TypeNoRemote).
+
 fields_from_form([], _TypeNames, _RecDict, _VarDict) ->
   {[], []};
 fields_from_form([{Name, Type}|Tail], TypeNames, RecDict,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20140509/b47f7700/attachment.htm>


More information about the erlang-bugs mailing list