Skip to content

Commit 412c175

Browse files
suggestions
1 parent 5930b06 commit 412c175

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

stdlib/REPL/src/REPL.jl

+16-17
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,17 @@ function repl_backend_loop(backend::REPLBackend, get_module::Function)
439439
# exit flag
440440
break
441441
end
442-
if ast_or_func isa Expr
443-
ast = ast_or_func
444-
eval_user_input(ast, backend, get_module())
445-
else
442+
if show_value == 2 # 2 indicates a function to be called
446443
f = ast_or_func
447444
try
448445
ret = f()
449446
put!(backend.response_channel, Pair{Any, Bool}(ret, false))
450447
catch err
451448
put!(backend.response_channel, Pair{Any, Bool}(err, true))
452449
end
450+
else
451+
ast = ast_or_func
452+
eval_user_input(ast, backend, get_module())
453453
end
454454
end
455455
return nothing
@@ -582,20 +582,19 @@ function print_response(errio::IO, response, backend::Union{REPLBackendRef,Nothi
582582
repl_display_error(errio, val)
583583
else
584584
if val !== nothing && show_value
585-
try
586-
if specialdisplay === nothing
587-
# display calls may require being run on the main thread
588-
eval_with_backend(backend) do
589-
Base.invokelatest(display, val)
590-
end
591-
else
592-
eval_with_backend(backend) do
593-
Base.invokelatest(display, specialdisplay, val)
594-
end
585+
val2, iserr = if specialdisplay === nothing
586+
# display calls may require being run on the main thread
587+
eval_with_backend(backend) do
588+
Base.invokelatest(display, val)
595589
end
596-
catch
590+
else
591+
eval_with_backend(backend) do
592+
Base.invokelatest(display, specialdisplay, val)
593+
end
594+
end
595+
if iserr
597596
println(errio, "Error showing value of type ", typeof(val), ":")
598-
rethrow()
597+
throw(val2)
599598
end
600599
end
601600
end
@@ -1154,7 +1153,7 @@ function eval_with_backend(ast::Expr, backend::REPLBackendRef)
11541153
return take!(backend.response_channel) # (val, iserr)
11551154
end
11561155
function eval_with_backend(f, backend::REPLBackendRef)
1157-
put!(backend.repl_channel, (f, false)) # (f, show_value)
1156+
put!(backend.repl_channel, (f, 2)) # (f, show_value) 2 indicates function (rather than ast)
11581157
return take!(backend.response_channel) # (val, iserr)
11591158
end
11601159
# if no backend just eval (used by tests)

0 commit comments

Comments
 (0)