Skip to content

Commit

Permalink
Run ast_transforms with invokelatest (JuliaLang#34778)
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy authored and birm committed Feb 22, 2020
1 parent 0495720 commit 5fdbd6e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend)
else
backend.in_eval = true
for xf in backend.ast_transforms
ast = xf(ast)
ast = Base.invokelatest(xf, ast)
end
value = Core.eval(Main, ast)
backend.in_eval = false
Expand Down
15 changes: 15 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1135,3 +1135,18 @@ fake_repl() do stdin_write, stdout_read, repl
write(stdin_write, "\x15\x04")
Base.wait(repltask)
end

# AST transformations (softscope, Revise, OhMyREPL, etc.)
repl_channel = Channel(1)
response_channel = Channel(1)
backend = REPL.start_repl_backend(repl_channel, response_channel)
put!(repl_channel, (:(1+1), false))
reply = take!(response_channel)
@test reply == (2, false)
twice(ex) = Expr(:tuple, ex, ex)
push!(backend.ast_transforms, twice)
put!(repl_channel, (:(1+1), false))
reply = take!(response_channel)
@test reply == ((2, 2), false)
put!(repl_channel, (nothing, -1))
Base.wait(backend.backend_task)

0 comments on commit 5fdbd6e

Please sign in to comment.