Skip to content

Commit

Permalink
Switch already_warned_path_change_pkgs to Set{PkgId}() (JuliaLang…
Browse files Browse the repository at this point in the history
  • Loading branch information
staticfloat committed Jan 7, 2024
1 parent e2b31cd commit 5cd61ec
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1989,13 +1989,19 @@ function __require_prelocked(uuidkey::PkgId, env=nothing)
return newm
end

const already_warned_path_change_pkgs = Set{UUID}()
const already_warned_path_change_pkgs = Set{PkgId}()
# warns if the loaded version of a module is different to the one that locate_package wants to load
function warn_if_already_loaded_different(uuidkey::PkgId)
uuidkey.uuid already_warned_path_change_pkgs && return
uuidkey already_warned_path_change_pkgs && return
pkgorig = get(pkgorigins, uuidkey, nothing)
if pkgorig !== nothing && pkgorig.path !== nothing
new_path = locate_package(uuidkey)
# `locate_package()` can throw an error; if that happens just skip
local new_path
try
new_path = locate_package(uuidkey)
catch
return
end

# new_path can be `nothing` if `uuidkey` is not loadable in this environment
if new_path === nothing
Expand Down Expand Up @@ -2027,10 +2033,7 @@ function warn_if_already_loaded_different(uuidkey::PkgId)
end
end
@warn warnstr
# Toplevel modules have a `uuid` of `Nothing`
if uuidkey.uuid !== nothing
push!(already_warned_path_change_pkgs, uuidkey.uuid)
end
push!(already_warned_path_change_pkgs, uuidkey)
end
end
end
Expand Down

0 comments on commit 5cd61ec

Please sign in to comment.