[erlang-questions] Dialyzer and try/after

Paul Guyot <>
Wed Aug 13 09:20:47 CEST 2008


Le 12 août 08 à 11:45, Richard Carlsson a écrit :

> We have identified the problem, which has more to do with how the
> compiler currently handles the code in the "after" block. We will
> try to improve this as soon as we can, but we can't guarantee that
> the fix gets in to the next release of OTP, which I think is due
> fairly soon.
>
> Meanwhile, the workaround is to manually lift the after...end
> part to a separate function; in your case:
>
>    ...
>    after
>        do_after(FooResult)
>    end,
>    Result.
>
> do_after(FooResult) ->
>      case FooResult of
>        {ok, _} ->
>          case foo_finalize(FooResult) of
>            ok -> ignore;
>            FinalizeError -> throw({barError, FinalizeError})
>          end;
>        _ ->
>          io:format("_ can match.~n")
>      end
>
> Hope this works for you.

Thanks for your reply. Tobias also mentioned I could introduce a  
bogus catch clause to avoid the dialyzer warning, which is what I've  
done with satisfaction, until the bug is fixed upstream :)

Paul




More information about the erlang-questions mailing list