Skip to content

Commit 624d5c4

Browse files
committed
Fix ~50 invalidations stemming from modules_to_be_loaded
ChainRulesCore defines `==(a, b::AbstractThunk)` and its converse, and these end up invaliding parts of the REPL (including `eval_user_input`) via inference failures in `modules_to_be_loaded`. Co-authored by: Jameson Nash <[email protected]>
1 parent 2ebbb2b commit 624d5c4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

stdlib/REPL/src/REPL.jl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ function eval_user_input(@nospecialize(ast), backend::REPLBackend)
168168
end
169169

170170
function check_for_missing_packages_and_run_hooks(ast)
171+
isa(ast, Expr) || return
171172
mods = modules_to_be_loaded(ast)
172173
filter!(mod -> isnothing(Base.identify_package(String(mod))), mods) # keep missing modules
173174
if !isempty(mods)
@@ -177,15 +178,17 @@ function check_for_missing_packages_and_run_hooks(ast)
177178
end
178179
end
179180

180-
function modules_to_be_loaded(ast, mods = Symbol[])
181+
function modules_to_be_loaded(ast::Expr, mods = Symbol[])
181182
if ast.head in [:using, :import]
182183
for arg in ast.args
183-
if first(arg.args) isa Symbol # i.e. `Foo`
184-
if first(arg.args) != :. # don't include local imports
185-
push!(mods, first(arg.args))
184+
arg = arg::Expr
185+
arg1 = first(arg.args)
186+
if arg1 isa Symbol # i.e. `Foo`
187+
if arg1 != :. # don't include local imports
188+
push!(mods, arg1)
186189
end
187190
else # i.e. `Foo: bar`
188-
push!(mods, first(first(arg.args).args))
191+
push!(mods, first((arg1::Expr).args))
189192
end
190193
end
191194
end
@@ -195,7 +198,6 @@ function modules_to_be_loaded(ast, mods = Symbol[])
195198
filter!(mod -> !in(String(mod), ["Base", "Main", "Core"]), mods) # Exclude special non-package modules
196199
return mods
197200
end
198-
modules_to_be_loaded(::Nothing) = Symbol[] # comments are parsed as nothing
199201

200202
"""
201203
start_repl_backend(repl_channel::Channel, response_channel::Channel)

0 commit comments

Comments
 (0)