Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: Don't look for missing packages in code that isn't going to be run #41887

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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