[erlang-questions] dialyzer underspecs warning

Krzesimir Sarnecki <>
Fri Aug 8 13:19:26 CEST 2014


Hello,

I'm learning how to use -specs + dialyzer and I encountered a problem.
I hope you could help me deal with it.

This is my test function:

test(Array, N, Value) ->
    array:set(N, Value, Array).

And this ia a spec I wrote for it:

-spec test(array:array(T), non_neg_integer(), T) -> array:array(T).

When I run dialyzer with -Wunderspecs flag it gives me a warning:
 
Type specification test:test(array:array(T),non_neg_integer(),T) 
-> array:array(T) is a supertype of the success typing: (very long
typing)

To my surprise when I change a spec to:

-spec test(array:array(T), non_neg_integer(), _) -> array:array(T).

Dialyzer doesn't give me the warning anymore.

Am I missing something or dialyzer is telling me that T is a supertype
of any()?

I looked into the source code of array module in stdlib and the -spec 
for set function is the same as my original -spec. Running dialyzer with
the same arguments on the array module doesn't give me warnings (at
least for this function).

What should the -spec for my function look like? And should I always run
dialyzer with -Wunderspecs flag, given it is not a default flag?

Thank you in advance,
K.



More information about the erlang-questions mailing list