@musm
After a too long investigation it turns out that it is not type stable
because draw_samples2 which I presume is the name you gave the generated function, is not const.
if you declare it using:
const draw_samples2 = fsamples_prealoc(draw_samples!,n)
then foo2 becomes type_stable.