[erlang-questions] opaque type definition makes dialyzer unhappy even in same module
Hynek Vychodil
hynek@REDACTED
Tue May 17 21:53:44 CEST 2011
The issue with tagging in this case is that it makes it will perform
worse. The code where this warning occurred I work with internal
structures. But it would be possible make some sort of internal
subtype without tag. Anyway I think that problems comes from
interaction with array module which doesn't preserve item type. But I
think the issue with opaque type is more likely bug. Dialyzer should
not complain about opacity violation for type defined in same module.
Anyway i'm trying pairing heap now which seems fits to erlang
functional nature better and also performs significantly better.
BTW Is there any way to suppress dialyzer warning by some sort of
annotation? For example perlcritic supports suppressing of known but
intentional violations by special comments.
On Tue, May 17, 2011 at 1:30 PM, Jamie Brandon
<jamie@REDACTED> wrote:
> 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
>>
>>
>
--
--Hynek (Pichi) Vychodil
Analyze your data in minutes. Share your insights instantly. Thrill
your boss. Be a data hero!
Try GoodData now for free: www.gooddata.com
More information about the erlang-questions
mailing list