Enforcing a function spec in Dialyzer
Zoltan Lajos Kis
kiszl@REDACTED
Thu Jun 17 19:28:36 CEST 2010
Hi all,
Is it possible to enforce Dialyzer to use the spec I provide for a function
instead of deducting the specification from the function body?
For example in the example below I would like to force my spec on the
data() function,
making Dialyzer stop issuing warnings about lists:keyfind always
returning false,
get(Key) always returning 'undefined', and so on...
(The rational behind the question is that I rebuild the module every now
and then,
so calling the data() function will actually return a list of key-value
pairs later.)
Thank you,
Zoltan.
----------------------
-spec( get(atom()) -> any() ).
get(Key) ->
case lists:keyfind(Key, 1, data()) of
{Key, Val} -> Val;
false -> 'undefined'
end.
-spec( data() -> [{atom(), any()}] ).
data() -> [].
More information about the erlang-questions
mailing list