Skip to content

Commit

Permalink
don't look for packages in code that isn't going to be run this eval (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Aug 14, 2021
1 parent 6f8bb64 commit 19629d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ function check_for_missing_packages_and_run_hooks(ast)
end

function modules_to_be_loaded(ast, mods = Symbol[])
ast.head == :quote && return mods # don't search if it's not going to be run during this eval
if ast.head in [:using, :import]
for arg in ast.args
if first(arg.args) isa Symbol # i.e. `Foo`
Expand Down
5 changes: 5 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,11 @@ end
mods = REPL.modules_to_be_loaded(Base.parse_input_line("using Core"))
@test isempty(mods)

mods = REPL.modules_to_be_loaded(Base.parse_input_line(":(using Foo)"))
@test isempty(mods)
mods = REPL.modules_to_be_loaded(Base.parse_input_line("ex = :(using Foo)"))
@test isempty(mods)

mods = REPL.modules_to_be_loaded(Base.parse_input_line("# comment"))
@test isempty(mods)
mods = REPL.modules_to_be_loaded(Base.parse_input_line("Foo"))
Expand Down

0 comments on commit 19629d7

Please sign in to comment.