I’m trying to build a pipeline of transformations and noticed this weird behavior when I plugged a Point2f0 constructor into the pipeline. I’ve removed the rest of the test pipeline and replaced it with the identity function to create the MWE.
That’s interesting–it looks like the closure that is built by the \circ operator ends up capturing f (the first function) as a field of the abstract type DataType:
and that makes the result of the composed function un-inferrable.
We can reproduce the issue without using \circ like so:
julia> function wrap(t)
x -> t(x)
end
wrap (generic function with 1 method)
julia> wrapped_point = wrap(Point2f0)
#14 (generic function with 1 method)
julia> @code_warntype wrapped_point(ps[1])
Variables
#self#::var"#14#15"{DataType}
x::Point{2,Float64}
Body::Any
1 ─ %1 = Core.getfield(#self#, :t)::DataType
│ %2 = (%1)(x)::Any
└── return %2
Seems like it would be worth opening an issue at Issues · JuliaLang/julia · GitHub , since this seems like a general issue with the way types are captured by closures.