Skip to content

Commit 4b4468a

Browse files
authored
repl: Also ignore local imports with specified symbols (#54982)
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.
1 parent 00c700e commit 4b4468a

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

stdlib/REPL/src/REPL.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,14 @@ function _modules_to_be_loaded!(ast::Expr, mods::Vector{Symbol})
285285
arg = arg::Expr
286286
arg1 = first(arg.args)
287287
if arg1 isa Symbol # i.e. `Foo`
288-
if arg1 != :. # don't include local imports
288+
if arg1 != :. # don't include local import `import .Foo`
289289
push!(mods, arg1)
290290
end
291291
else # i.e. `Foo: bar`
292-
push!(mods, first((arg1::Expr).args))
292+
sym = first((arg1::Expr).args)::Symbol
293+
if sym != :. # don't include local import `import .Foo: a`
294+
push!(mods, sym)
295+
end
293296
end
294297
end
295298
end

stdlib/REPL/test/repl.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,6 +1478,11 @@ end
14781478
@test isempty(mods)
14791479
mods = REPL.modules_to_be_loaded(Base.parse_input_line("begin using Foo; Core.eval(Main,\"using Foo\") end"))
14801480
@test mods == [:Foo]
1481+
1482+
mods = REPL.modules_to_be_loaded(:(import .Foo: a))
1483+
@test isempty(mods)
1484+
mods = REPL.modules_to_be_loaded(:(using .Foo: a))
1485+
@test isempty(mods)
14811486
end
14821487
end
14831488

0 commit comments

Comments
 (0)