[erlang-questions] opaque type definition makes dialyzer unhappy even in same module

Jamie Brandon jamie@REDACTED
Tue May 17 13:30:26 CEST 2011


I ran into the same problem a few days ago. Dialyzer doesn't like
opaque types which are simple aliases. if you add a tag (and modify
the rest of the code accordingly) it should work fine:

-type fib_heap() :: {fib_heap, [fib_heap_node()]}.

This will also make debugging easier if fib_heap shows up in an error report.

On 16 May 2011 04:16, Hynek Vychodil <hynek@REDACTED> wrote:
> Hi,
>
> I'm playing with dialyzer in mine attempt to fibonacci heap
> implementation and I got weird behavior. When I define fib_heap() as
> type dialyzer seems happy but when I change it to -opaque it produce
> warnings below
>
> $ dialyzer fib_heap.erl
>  Checking whether the PLT /home/hynek/.dialyzer_plt is up-to-date... yes
>  Proceeding with analysis...
> fib_heap.erl:32: The call fib_heap:reset_min_(H::[any()]) does not
> have an opaque term of type fib_heap:fib_heap() as 1st argument
> fib_heap.erl:46: The call fib_heap:reset_min_(T::[any()],H::any(),[])
> does not have opaque terms as 1st and 3rd arguments
> fib_heap.erl:53: The call
> fib_heap:reset_min_(T::[any()],H::{_,_},[any(),...]) does not have
> opaque terms as 1st and 3rd arguments
> fib_heap.erl:55: The call
> fib_heap:reset_min_(T::[any()],Min::any(),[any(),...]) does not have
> opaque terms as 1st and 3rd arguments
> fib_heap.erl:64: The call
> fib_heap:compact_(nonempty_maybe_improper_list(),array()) does not
> have an opaque term of type fib_heap:fib_heap() as 1st argument
>  done in 0m0.72s
> done (warnings were emitted)
>
> What is going on? According to documentation: "Types declared as
> opaque represent sets of terms whose structure is not supposed to be
> visible in any way outside of their defining module (i.e., only the
> module defining them is allowed to depend on their term structure)." I
> only changed '-type' to '-opaque' on line 8, I stay in same module but
> dialyzer emits warnings which I don't understand and don't know how I
> should fix or suppress.
>
> --
> --Hynek (Pichi) Vychodil
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list