It depends on what @atteson was hoping to accomplish. I read the code as an attempt to force the element type of the AbstractVector y to be the same as the type of the argument passed into f1.
If that was the intent then adding the second where T won’t work since T gets bound to a different type in f2:
julia> function f1( x::T ) where {T}
function f2( y::U ) where {U <: AbstractVector{T}} where T
return 0.0
end
return f2
end
f1 (generic function with 1 method)
julia> a = f1(1.0)
(::var"#f2#12") (generic function with 1 method)
julia> a(["this","that"])
0.0
This alternative forces the element type of y to be the same as the type of the argument to f1:
julia> function f1(x::T ) where {T}
function f2(y::AbstractVector{T})
return 0.0
end
return f2
end
f1 (generic function with 1 method)
julia> a = f1(1.0)
(::var"#f2#11"{Float64}) (generic function with 1 method)
julia> a([1.0,2.0])
0.0
julia> a([1,2])
ERROR: MethodError: no method matching (::var"#f2#11"{Float64})(::Vector{Int64})
Closest candidates are:
(::var"#f2#11"{T})(::AbstractVector{T}) where T at REPL[24]:2
Stacktrace:
[1] top-level scope
@ REPL[27]:clock130: