A parametric vararg resumable function throws when it's called with no arguments.
using ResumableFunctions
@resumable function res(a::T...) where T
@yield length(a)
end
collect(res(1, 2)) # Any[2]
collect(res()) # UndefVarError: `T` not defined in static parameter matching
The plain function returns 0 there. The wrapper constructs the state machine as ##res_FSMI#...{T}, and an empty vararg leaves T unbound.
Recursion that peels arguments off hits it on the last step:
@resumable function peel(a::T...) where T
if !isempty(a)
@yield first(a)
@yieldfrom peel(Base.tail(a)...)
end
end
collect(peel(1, 2, 3)) # same UndefVarError
v1.0.7, same on julia 1.10.10, 1.11.9 and 1.12.7. On 1.10 the message is just UndefVarError: T not defined.
A parametric vararg resumable function throws when it's called with no arguments.
The plain function returns 0 there. The wrapper constructs the state machine as
##res_FSMI#...{T}, and an empty vararg leavesTunbound.Recursion that peels arguments off hits it on the last step:
v1.0.7, same on julia 1.10.10, 1.11.9 and 1.12.7. On 1.10 the message is just
UndefVarError: T not defined.