MWE:
julia> using AbstractAlgebra, Test
julia> M = FreeModule(ZZ, 1);
julia> f = ModuleHomomorphism(M, M, identity_matrix(ZZ, 1));
julia> m = only(gens(M));
julia> @inferred f(m)
ERROR: return type AbstractAlgebra.Generic.FreeModuleElem{BigInt} does not match inferred return type Any
MWE: