JuliaDynamics / ResumableFunctions.jl

C# style generators a.k.a. semi-coroutines for Julia.
Other
160 stars 19 forks source link

Resumable functions do not recognize types in same module #9

Closed ianfiske closed 6 years ago

ianfiske commented 7 years ago

If we define a @resumable function in a module, using a type defined in the same module as an argument type, we get an error:

module testresumable

using SimJulia, ResumableFunctions

struct A
    x::Float64
end

@resumable function myprocess(sim::Simulation, a::A)
    @yield timeout(sim, 10)
end

end

This gives the error UndefVarError: A not defined. I am using

BenLauwens commented 7 years ago

The problem is caused by an (evil) eval statement in utils.jl. This is needed for type inference ... I have added a fix to the master branch. (Pkg.checkout("ResumableFunctions")) Can you verify that this solves your problem? If so I will do a new release. Thanks

ianfiske commented 7 years ago

I just verified that your update works for me in master. Thank you for the fix!