Skip to content

Commit

Permalink
Missing package add prompt: Restrict which exprs to search in (#43457)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth authored Jan 1, 2022
1 parent c04a3fd commit 8f192bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ function modules_to_be_loaded(ast::Expr, mods::Vector{Symbol} = Symbol[])
end
end
for arg in ast.args
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
9 changes: 9 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,15 @@ end

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

mods = REPL.modules_to_be_loaded(Base.parse_input_line("@eval using Foo"))
@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

2 comments on commit 8f192bd

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

Please sign in to comment.