From fa851b927e07ebf9097cc81dd2e1b0e3acebb920 Mon Sep 17 00:00:00 2001 From: Matt Bauman Date: Tue, 18 Jun 2019 18:29:28 -0400 Subject: [PATCH] Support at-overdub with assignments This very basic change allows you to at-overdub a single expression that assigns to a value, which is useful if, for example, you are implementing a cassette transform in a custom REPL --- src/overdub.jl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/overdub.jl b/src/overdub.jl index 3ca8b34..eeec726 100644 --- a/src/overdub.jl +++ b/src/overdub.jl @@ -660,5 +660,8 @@ macro roughly expands to `Cassette.recurse(ctx, () -> expression)`. See also: [`overdub`](@ref), [`recurse`](@ref) """ macro overdub(ctx, expr) + if Base.Meta.isexpr(expr, :(=)) + return Expr(:(=), esc(expr.args[1]), :(@overdub($(esc(ctx)), $(esc(expr.args[2]))))) + end return :(recurse($(esc(ctx)), () -> $(esc(expr)))) end