JuliaDynamics/ResumableFunctions.jl

Recursive parametric functions troubles?

bottine opened this issue · 0 comments

EDIT. After some more fiddling, it appears that the culprit is actually the double definition of f.
Since I'm not sure if it's expected behaviour, I'll leave the issue open just in case.


Hi,

First, thanks for this fine package!
I'm trying to make the following code run:

using ResumableFunctions
using StaticArrays


@resumable function f(
    b::SVector{1,Int},
) ::SVector{1,Int} 
    
    @yield SVector{1,Int}(0)
    
end


@resumable function f(
    b::SVector{rk, Int},
):: SVector{rk,Int}  where {rk}
    
    for s in f(SVector{rk-1,Int}(b[1:end-1]))
        @yield vcat(s,SVector{1,Int}(1))
    end
end

for i in f(SVector{3,Int}(0,0,0)) println(i) end

but this yields the error

LoadError: MethodError: Cannot `convert` an object of type var"##256"{2} to an object of type var"##254"

Removing all type parameters makes the code compile. Is this a bug in the library or am I doing something wrong?

Thanks!