@@ -79,9 +79,9 @@ const JULIA_PROMPT = "julia> "
79
79
80
80
mutable struct REPLBackend
81
81
" channel for AST"
82
- repl_channel:: Channel
82
+ repl_channel:: Channel{Any}
83
83
" channel for results: (value, iserror)"
84
- response_channel:: Channel
84
+ response_channel:: Channel{Any}
85
85
" flag indicating the state of this backend"
86
86
in_eval:: Bool
87
87
" transformation functions to apply before evaluating expressions"
@@ -130,7 +130,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend)
130
130
try
131
131
Base. sigatomic_end ()
132
132
if lasterr != = nothing
133
- put! (backend. response_channel, (lasterr,true ))
133
+ put! (backend. response_channel, Pair {Any, Bool} (lasterr, true ))
134
134
else
135
135
backend. in_eval = true
136
136
for xf in backend. ast_transforms
@@ -140,7 +140,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend)
140
140
backend. in_eval = false
141
141
# note: use jl_set_global to make sure value isn't passed through `expand`
142
142
ccall (:jl_set_global , Cvoid, (Any, Any, Any), Main, :ans , value)
143
- put! (backend. response_channel, (value,false ))
143
+ put! (backend. response_channel, Pair {Any, Bool} (value, false ))
144
144
end
145
145
break
146
146
catch err
@@ -156,14 +156,14 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend)
156
156
end
157
157
158
158
"""
159
- start_repl_backend(repl_channel::Channel,response_channel::Channel)
159
+ start_repl_backend(repl_channel::Channel, response_channel::Channel)
160
160
161
161
Starts loop for REPL backend
162
162
Returns a REPLBackend with backend_task assigned
163
163
164
164
Deprecated since sync / async behavior cannot be selected
165
165
"""
166
- function start_repl_backend (repl_channel:: Channel , response_channel:: Channel )
166
+ function start_repl_backend (repl_channel:: Channel{Any} , response_channel:: Channel{Any} )
167
167
# Maintain legacy behavior of asynchronous backend
168
168
backend = REPLBackend (repl_channel, response_channel, false )
169
169
# Assignment will be made twice, but will be immediately available
@@ -209,29 +209,30 @@ end
209
209
== (a:: REPLDisplay , b:: REPLDisplay ) = a. repl === b. repl
210
210
211
211
function display (d:: REPLDisplay , mime:: MIME"text/plain" , x)
212
+ x = Ref {Any} (x)
212
213
with_repl_linfo (d. repl) do io
213
214
io = IOContext (io, :limit => true , :module => Main:: Module )
214
215
get (io, :color , false ) && write (io, answer_color (d. repl))
215
216
if isdefined (d. repl, :options ) && isdefined (d. repl. options, :iocontext )
216
217
# this can override the :limit property set initially
217
218
io = foldl (IOContext, d. repl. options. iocontext, init= io)
218
219
end
219
- show (io, mime, x)
220
+ show (io, mime, x[] )
220
221
println (io)
221
222
end
222
223
return nothing
223
224
end
224
225
display (d:: REPLDisplay , x) = display (d, MIME (" text/plain" ), x)
225
226
226
- function print_response (repl:: AbstractREPL , @nospecialize ( response) , show_value:: Bool , have_color:: Bool )
227
+ function print_response (repl:: AbstractREPL , response, show_value:: Bool , have_color:: Bool )
227
228
repl. waserror = response[2 ]
228
229
with_repl_linfo (repl) do io
229
230
io = IOContext (io, :module => Main:: Module )
230
231
print_response (io, response, show_value, have_color, specialdisplay (repl))
231
232
end
232
233
return nothing
233
234
end
234
- function print_response (errio:: IO , @nospecialize ( response) , show_value:: Bool , have_color:: Bool , specialdisplay:: Union{AbstractDisplay,Nothing} = nothing )
235
+ function print_response (errio:: IO , response, show_value:: Bool , have_color:: Bool , specialdisplay:: Union{AbstractDisplay,Nothing} = nothing )
235
236
Base. sigatomic_begin ()
236
237
val, iserr = response
237
238
while true
279
280
280
281
# A reference to a backend that is not mutable
281
282
struct REPLBackendRef
282
- repl_channel:: Channel
283
- response_channel:: Channel
283
+ repl_channel:: Channel{Any}
284
+ response_channel:: Channel{Any}
284
285
end
285
286
REPLBackendRef (backend:: REPLBackend ) = REPLBackendRef (backend. repl_channel, backend. response_channel)
286
287
function destroy (ref:: REPLBackendRef , state:: Task )
@@ -791,7 +792,7 @@ function respond(f, repl, main; pass_empty::Bool = false, suppress_on_semicolon:
791
792
ast = Base. invokelatest (f, line)
792
793
response = eval_with_backend (ast, backend (repl))
793
794
catch
794
- response = (catch_stack (), true )
795
+ response = Pair {Any, Bool} (catch_stack (), true )
795
796
end
796
797
hide_output = suppress_on_semicolon && ends_with_semicolon (line)
797
798
print_response (repl, response, ! hide_output, hascolor (repl))
@@ -942,7 +943,7 @@ function setup_interface(
942
943
hist_from_file (hp, hist_path)
943
944
catch
944
945
# use REPL.hascolor to avoid using the local variable with the same name
945
- print_response (repl, (catch_stack (),true ), true , REPL. hascolor (repl))
946
+ print_response (repl, Pair {Any, Bool} (catch_stack (), true ), true , REPL. hascolor (repl))
946
947
println (outstream (repl))
947
948
@info " Disabling history file for this session"
948
949
repl. history_file = false
0 commit comments