Resumable function as a struct field var...error: "struct" expression not at top level

Greetings,
A resumable function (singleton type of function , subtype of Function) , when put as a struct field variable, causes the error “struct expression not at top level” while a normal function does not. Could anyone explain? thanks

using ResumableFunctions
struct foo
    f::Function
end
function test()
    @resumable function f(i::Int)
        if i==1
            @yield 1
        else
            @yield 2
        end
    end
    odepro=foo(f)
end

@resumable transforms the function block to a larger expression that includes a mutable struct block. struct blocks can only be defined in the global scope, like where struct foo is. The error is thrown before foo(f) even runs, foo’s field is not the cause of the issue.