Understanding/fixing delayed trigger of Revise.revise in manual mode

I’m having trouble getting Revise.revise() to take effect (right away) when either called in a loop, a script, or a wrapper function that also calls the (non-inlined) function that needs revising.

I put together a self-contained example – hoping someone can explain what’s happening / how I should be approaching this.

Use case detailed here (ReviseLoop.jl).

Script with tests enumerating the unexpected behavior here (ReviseLoop.jl/src/script.jl)

Any idea why the test marked “Issue ‘1’” is failing when run as a script vs in the repl, and why “Issue ‘2’” shows the update is not reflected until the function is called twice?

I’m sure this is easy to do right and I’m just missing something.

Try replacing f(args...; kwargs...) with Base.invokelatest(f, args...; kwargs...)). I believe you have world age issues, rather than Revise issues.

1 Like

@cstjean Thank you!

invokelatest cleared up Revise’s behavior for me in the REPL, but not when running the same script non-interactively (https://github.com/garborg/ReviseLoop.jl/blob/invokelatest/src/script.jl).

I read up on the basics of world age in a repl context here manual/methods/#Redefining-Methods-1, but I think I still need to figure out the interplay between world age, invokelatest, and scoping outside the REPL.