Skip to content

Commit

Permalink
repl: Also ignore local imports with specified symbols (#54982)
Browse files Browse the repository at this point in the history
Otherwise it's trying to find the `.` package, which obviously doesn't
exist. This isn't really a problem - it just does some extra processing
and loads Pkg, but let's make this correct anyway.
  • Loading branch information
Keno authored Jul 1, 2024
1 parent 00c700e commit 4b4468a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,14 @@ function _modules_to_be_loaded!(ast::Expr, mods::Vector{Symbol})
arg = arg::Expr
arg1 = first(arg.args)
if arg1 isa Symbol # i.e. `Foo`
if arg1 != :. # don't include local imports
if arg1 != :. # don't include local import `import .Foo`
push!(mods, arg1)
end
else # i.e. `Foo: bar`
push!(mods, first((arg1::Expr).args))
sym = first((arg1::Expr).args)::Symbol
if sym != :. # don't include local import `import .Foo: a`
push!(mods, sym)
end
end
end
end
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 @@ -1478,6 +1478,11 @@ end
@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]

mods = REPL.modules_to_be_loaded(:(import .Foo: a))
@test isempty(mods)
mods = REPL.modules_to_be_loaded(:(using .Foo: a))
@test isempty(mods)
end
end

Expand Down

0 comments on commit 4b4468a

Please sign in to comment.