In mnesia_tm:execute_transaction
, the provided fun is being called inside a catch
, which means that the return type collapses into term()
as far as Dialyzer is concerned. Thus Dialyzer is unable to conclude that the return type of mnesia:activity/2
is the same as that of the provided function, and thus needs an explicit type spec to that effect.
Besides, I believe that Dialyzer generally never infers a return value type based on the return value of a function provided as an argument. For example, with this module:
-module(foo).
-export([foo/1]).
foo(F) ->
F(42).
typer shows the following:
$ typer /tmp/foo.erl
%% File: "/tmp/foo.erl"
%% --------------------
-spec foo(fun((_) -> any())) -> any().
though if I add the explicit type spec -spec foo(fun((_) -> X)) -> X.
, then typer accepts it.
(I'm sure the Dialyzer developers will have a more complete and insightful answer to this.)