Type instability in Folds.map

Hello, I’ve noticed that the Folds version of map() seems to introduce type instability:

using Folds
f1(K::Integer) = map(identity, 1:K) 
f2(K::Integer) = Folds.map(identity, 1:K) 

@code_warntype f1(5)
@code_warntype f2(5)

Does anyone have any suggestions as to why this is happening and possible remedies?

2 Likes