JuliaDynamics/ResumableFunctions.jl

Doesn't work in file I/O do-blocks

Malthanatos opened this issue · 1 comments

Using Julia 1.0.0 and ResumablePackages 0.4.1

I can get around it by simply doing non-block based I/O lines so it isn't a huge deal, but the below block of code gives the following error:

using ResumableFunctions

@resumable function f(file::String)
    open(file, "r") do io              # works if you instead use: io = open(file,"r")
        lines = readlines(io)
        for line in lines
            @yield line
        end
    end                                # and replace this with: close(io)
end;

for line in f("test.txt")
    println(line)
end

ERROR: LoadError: syntax: label "_STATE_1" referenced but not defined
Stacktrace:
[1] include at .\boot.jl:317 [inlined]
[2] include_relative(::Module, ::String) at .\loading.jl:1038
[3] include(::Module, ::String) at .\sysimg.jl:29
[4] exec_options(::Base.JLOptions) at .\client.jl:229
[5] _start() at .\client.jl:421
in expression starting at C:\...\file.jl:3

Hi

a do block is an anonymous function in disguise and we can not do "@goto" into another function. So this can not be fixed. Sorry for the late response!
Kind regards

Ben