Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit convert(String, ...) in several places #56174

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions base/precompilation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Collect all direct dependencies of the project
for key in ["deps", "weakdeps", "extras"]
for (name, _uuid::String) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
Copy link
Member Author

Choose a reason for hiding this comment

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

It is a shame that this behaves like:

_uuid::String
_uuid = unpacked_val # implicit `convert`

instead of:

_uuid = unpacked_val::String

or even:

_uuid::String = unpacked_val::String

The original author of this code clearly thought that was how this worked, and TBH so did I until I looked at the code_typed

Copy link
Member

Choose a reason for hiding this comment

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

This is all @KristofferC's new code that allowed parallel precompilation to leave Pkg. Just tagging to check intention on these converts, as I've been marked for review.

Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW I'm pretty confident the new annotations are correct - I just wanted to leave a note behind about the weird semantics here (it almost feels like a lowering bug that it behaves this way)

for (name, _uuid) in get(Dict{String, Any}, project_d, key)::Dict{String, Any}
v = key == "deps" ? project_deps :
key == "weakdeps" ? project_weakdeps :
key == "extras" ? project_extras :
error()
uuid = UUID(_uuid)
uuid = UUID(_uuid::String)
v[name] = uuid
names[UUID(uuid)] = name
project_uuid_to_name[name] = UUID(uuid)
Expand All @@ -75,9 +75,11 @@ function ExplicitEnv(envpath::String=Base.active_project())

project_extensions = Dict{String, Vector{UUID}}()
# Collect all extensions of the project
for (name, triggers::Union{String, Vector{String}}) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
for (name, triggers) in get(Dict{String, Any}, project_d, "extensions")::Dict{String, Any}
if triggers isa String
triggers = [triggers]
else
triggers = triggers::Vector{String}
end
uuids = UUID[]
for trigger in triggers
Expand Down Expand Up @@ -107,8 +109,9 @@ function ExplicitEnv(envpath::String=Base.active_project())
sizehint!(name_to_uuid, length(manifest_d))
sizehint!(lookup_strategy, length(manifest_d))

for (name, pkg_infos::Vector{Any}) in get_deps(manifest_d)
for pkg_info::Dict{String, Any} in pkg_infos
for (name, pkg_infos) in get_deps(manifest_d)
for pkg_info in pkg_infos::Vector{Any}
pkg_info = pkg_info::Dict{String, Any}
m_uuid = UUID(pkg_info["uuid"]::String)

# If we have multiple packages with the same name we will overwrite things here
Expand All @@ -129,8 +132,8 @@ function ExplicitEnv(envpath::String=Base.active_project())
# Expanded format:
else
uuids = UUID[]
for (name_dep, _dep_uuid::String) in deps_pkg
dep_uuid = UUID(_dep_uuid)
for (name_dep, _dep_uuid) in deps_pkg
dep_uuid = UUID(_dep_uuid::String)
push!(uuids, dep_uuid)
names[dep_uuid] = name_dep
end
Expand All @@ -140,9 +143,11 @@ function ExplicitEnv(envpath::String=Base.active_project())

# Extensions
deps_pkg = get(Dict{String, Any}, pkg_info, "extensions")::Dict{String, Any}
for (ext, triggers::Union{String, Vector{String}}) in deps_pkg
for (ext, triggers) in deps_pkg
if triggers isa String
triggers = [triggers]
else
triggers = triggers::Vector{String}
end
deps_pkg[ext] = triggers
end
Expand Down
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ mutable struct Regex <: AbstractPattern

function Regex(pattern::AbstractString, compile_options::Integer,
match_options::Integer)
pattern = String(pattern)
pattern = String(pattern)::String
compile_options = UInt32(compile_options)
match_options = UInt32(match_options)
if (compile_options & ~PCRE.COMPILE_MASK) != 0
Expand Down
2 changes: 1 addition & 1 deletion stdlib/REPL/src/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ region_active(s::PromptState) = s.region_active
region_active(s::ModeState) = :off


input_string(s::PromptState) = String(take!(copy(s.input_buffer)))
input_string(s::PromptState) = String(take!(copy(s.input_buffer)))::String

input_string_newlines(s::PromptState) = count(c->(c == '\n'), input_string(s))
function input_string_newlines_aftercursor(s::PromptState)
Expand Down