Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run ast_transforms with invokelatest #34778

Merged
merged 2 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1133,3 +1133,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)