Skip to content

Commit bb1a6ce

Browse files
authored
fix #35771, global a as repl input (#35775)
1 parent 7abd5ad commit bb1a6ce

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stdlib/REPL/src/REPL.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ function softscope(@nospecialize ex)
104104
return ex′
105105
elseif h in (:meta, :import, :using, :export, :module, :error, :incomplete, :thunk)
106106
return ex
107+
elseif h === :global && all(x->isa(x, Symbol), ex.args)
108+
return ex
107109
else
108110
return Expr(:block, Expr(:softscope, true), ex)
109111
end

stdlib/REPL/test/repl.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,18 @@ fake_repl() do stdin_write, stdout_read, repl
11461146
Base.wait(repltask)
11471147
end
11481148

1149+
# issue #35771
1150+
fake_repl() do stdin_write, stdout_read, repl
1151+
repltask = @async begin
1152+
REPL.run_repl(repl)
1153+
end
1154+
write(stdin_write, "global x\n")
1155+
readline(stdout_read)
1156+
@test !occursin("ERROR", readline(stdout_read))
1157+
write(stdin_write, '\x04')
1158+
Base.wait(repltask)
1159+
end
1160+
11491161

11501162
fake_repl() do stdin_write, stdout_read, repl
11511163
repltask = @async begin

0 commit comments

Comments
 (0)