Skip to content

Commit

Permalink
review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Dec 31, 2021
1 parent 24e395d commit 0ec75fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,9 @@ function modules_to_be_loaded(ast::Expr, mods::Vector{Symbol} = Symbol[])
end
end
for arg in ast.args
arg == Symbol("@eval") && break # don't search beyond an `@eval`
arg isa Expr && modules_to_be_loaded(arg, mods)
if arg isa Expr && arg.head in [:block, :if, :using, :import]
modules_to_be_loaded(arg, mods)
end
end
filter!(mod -> !in(String(mod), ["Base", "Main", "Core"]), mods) # Exclude special non-package modules
return unique(mods)
Expand Down
4 changes: 4 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,10 @@ end
@test isempty(mods)
mods = REPL.modules_to_be_loaded(Base.parse_input_line("begin using Foo; @eval using Bar end"))
@test mods == [:Foo]
mods = REPL.modules_to_be_loaded(Base.parse_input_line("Core.eval(Main,\"using Foo\")"))
@test isempty(mods)
mods = REPL.modules_to_be_loaded(Base.parse_input_line("begin using Foo; Core.eval(Main,\"using Foo\") end"))
@test mods == [:Foo]
end
end

Expand Down

0 comments on commit 0ec75fe

Please sign in to comment.