In the example below, if I comment the line marked with # !!!!!!!!!! I get ::Any.
module MyTest2
using Parameters
function build_model(list_of_settings)
function model(x; pars)
return sum(p*single_term_model(x; settings=s)
for (p,s) in zip(pars, list_of_settings))
end
return model
end
function single_term_model(x; settings)
@unpack N, k, p = settings
value = sum((k*x)^i*cis(i*p*x) for i in 1:N)
return value
end
export build_model
end
using .MyTest2
const list_of_settings = [(N=3,k=0.1,p=0.3),
(N=5,k=0.5,p=0.3),
(N=7,k=0.2,p=0.3)]
#
#!!!!!!!!!!
# @code_warntype MyTest2.single_term_model(2.2; settings=list_of_settings[1]) # correct! Complex{Float}
#!!!!!!!!!!
#
const model = build_model(list_of_settings)
@code_warntype model(2.2; pars=[1.0, 1.0, 1.0]) # Body::Any
As soon as I uncomment the line, I get Body::Complex{Float64}