[erlang-questions] Dialyzer safe way to test failure

Jay Nelson jay@REDACTED
Sun Dec 7 01:06:48 CET 2014


The following tests in my common_test suite:

    true = try ?TM:reserve(atom_to_list(Cache_Name), Cache_Module) catch error:function_clause -> true end,
    true = try ?TM:reserve(Cache_Name, atom_to_list(Cache_Module)) catch error:function_clause -> true end,

cause dialyzer to complain:

cxy_cache_SUITE.erl:58: The call cxy_cache:reserve(string(),Cache_Module::atom()) will never return since the success typing is (atom(),atom()) -> atom() | {'error','already_exists'} and the contract is (Name,module()) -> Name | {'error','already_exists'} when is_subtype(Name,cache_name())
cxy_cache_SUITE.erl:59: The call cxy_cache:reserve(Cache_Name::atom(),string()) will never return since the success typing is (atom(),atom()) -> atom() | {'error','already_exists'} and the contract is (Name,module()) -> Name | {'error','already_exists'} when is_subtype(Name,cache_name())


Is there a better way to check for failure when a non-string is passed as an arg to a function
that expects two atoms?

jay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141206/8322c05f/attachment.htm>


More information about the erlang-questions mailing list