Dialyzer and throw/catch
Gordon Guthrie
gordon@REDACTED
Sat Dec 4 22:16:18 CET 2010
On further investigation is seems the problem might be with the function
that is being called. The dialyzer error for it is:
muin_util.erl:227: The call
error_logger:error_msg({'error',_,[{atom(),atom(),[any()] | byte()}]} |
{'throw',_,[{atom(),atom(),[any()] | byte()}]}) will never return since the
success typing is (string()) -> 'ok' and the contract is (Format::string())
-> 'ok'
There is no spec for muin_util:atttempt/3 so I am not sure where this
'success typing' is coming from..
Gordon
On 4 December 2010 20:53, Gordon Guthrie <gordon@REDACTED> wrote:
> Sorry the dialyzer messages should have read:
>
>
> muin.erl:88: The pattern {'error', Err = {'aborted', _}} can never match
> the type {'ok',_}
> muin.erl:90: The pattern {'error', ErrVal} can never match the type
> {'ok',_}
>
> The other ones are from elsewhere in the module
>
> G
>
>
> On 4 December 2010 20:52, Gordon Guthrie <gordon@REDACTED> wrote:
>
>> Folks
>>
>> I am getting a dialyzer error that doesn't seem write.
>>
>> Here is the code:
>>
>> case Value of
>> R when ?is_cellref(R) ->
>> case muin_util:attempt(?MODULE, fetch, [R]) of
>> {ok, blank} -> 0;
>> {error, {aborted, _} = Err} -> exit(Err);
>> {ok, Other} -> Other;
>> {error, ErrVal} -> ErrVal
>> end;
>>
>> It call the function muin_util:attempt/3 which looks like:
>>
>> attempt(Mod, F, Args) ->
>> try apply(Mod, F, Args) of
>> Val -> {ok, Val}
>> catch
>> Error:Reason when Error =:= error orelse Error =:= throw ->
>> error_logger:error_msg({Error, Reason,
>> erlang:get_stacktrace()}),
>> {error, Reason}
>> end.
>>
>> Dialyzer gives the following warning:
>>
>> muin.erl:88: The pattern {'error', Err = {'aborted', _}} can never match
>> the type {'ok',_}
>> muin.erl:90: The pattern {'error', ErrVal} can never match the type
>> {'ok',_}
>> muin.erl:134: The pattern {'error', Err = {'errval', _}} can never match
>> the type {'ok',_}
>> muin.erl:135: The pattern {'error', Err = {'aborted', _}} can never match
>> the type {'ok',_}
>> muin.erl:136: The pattern {'error', _E} can never match the type {'ok',_}
>>
>> The function attempt/3 can return both the {'error', ...} patterns it
>> objects to, from the catch...
>>
>> Am I missing something?
>>
>> Gordon
>>
>> --
>> Gordon Guthrie
>> CEO hypernumbers
>>
>> http://hypernumbers.com
>> t: hypernumbers
>> +44 7776 251669
>>
>
>
>
> --
> Gordon Guthrie
> CEO hypernumbers
>
> http://hypernumbers.com
> t: hypernumbers
> +44 7776 251669
>
--
Gordon Guthrie
CEO hypernumbers
http://hypernumbers.com
t: hypernumbers
+44 7776 251669
More information about the erlang-questions
mailing list