Skip to content

Commit

Permalink
Merge pull request #44237 from JuliaLang/backports-release-1.8
Browse files Browse the repository at this point in the history
release-1.8: Backports for julia 1.8-beta1
  • Loading branch information
KristofferC authored Feb 23, 2022
2 parents 7a1c20e + a274328 commit a10115e
Show file tree
Hide file tree
Showing 44 changed files with 393 additions and 170 deletions.
6 changes: 3 additions & 3 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,6 @@ include("weakkeydict.jl")

include("env.jl")

# BinaryPlatforms, used by Artifacts
include("binaryplatforms.jl")

# functions defined in Random
function rand end
function randn end
Expand Down Expand Up @@ -336,6 +333,9 @@ using .Order
include("sort.jl")
using .Sort

# BinaryPlatforms, used by Artifacts. Needs `Sort`.
include("binaryplatforms.jl")

# Fast math
include("fastmath.jl")
using .FastMath
Expand Down
10 changes: 6 additions & 4 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1712,13 +1712,15 @@ end
_cs(d, a, b) = (a == b ? a : throw(DimensionMismatch(
"mismatch in dimension $d (expected $a got $b)")))

function dims2cat(::Val{n}) where {n}
n <= 0 && throw(ArgumentError("cat dimension must be a positive integer, but got $n"))
ntuple(i -> (i == n), Val(n))
function dims2cat(::Val{dims}) where dims
if any((0), dims)
throw(ArgumentError("All cat dimensions must be positive integers, but got $dims"))
end
ntuple(in(dims), maximum(dims))
end

function dims2cat(dims)
if any(dims .<= 0)
if any((0), dims)
throw(ArgumentError("All cat dimensions must be positive integers, but got $dims"))
end
ntuple(in(dims), maximum(dims))
Expand Down
5 changes: 4 additions & 1 deletion base/abstractdict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ empty(a::AbstractDict) = empty(a, keytype(a), valtype(a))
empty(a::AbstractDict, ::Type{V}) where {V} = empty(a, keytype(a), V) # Note: this is the form which makes sense for `Vector`.

copy(a::AbstractDict) = merge!(empty(a), a)
copy!(dst::AbstractDict, src::AbstractDict) = merge!(empty!(dst), src)
function copy!(dst::AbstractDict, src::AbstractDict)
dst === src && return dst
merge!(empty!(dst), src)
end

"""
merge!(d::AbstractDict, others::AbstractDict...)
Expand Down
5 changes: 4 additions & 1 deletion base/abstractset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
eltype(::Type{<:AbstractSet{T}}) where {T} = @isdefined(T) ? T : Any
sizehint!(s::AbstractSet, n) = nothing

copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
function copy!(dst::AbstractSet, src::AbstractSet)
dst === src && return dst
union!(empty!(dst), src)
end

## set operations (union, intersection, symmetric difference)

Expand Down
17 changes: 10 additions & 7 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -402,17 +402,20 @@ julia> getindex(Int8, 1, 2, 3)
"""
function getindex(::Type{T}, vals...) where T
a = Vector{T}(undef, length(vals))
@inbounds for i = 1:length(vals)
a[i] = vals[i]
if vals isa NTuple
@inbounds for i in 1:length(vals)
a[i] = vals[i]
end
else
# use afoldl to avoid type instability inside loop
afoldl(1, vals...) do i, v
@inbounds a[i] = v
return i + 1
end
end
return a
end

getindex(::Type{T}) where {T} = (@inline; Vector{T}())
getindex(::Type{T}, x) where {T} = (@inline; a = Vector{T}(undef, 1); @inbounds a[1] = x; a)
getindex(::Type{T}, x, y) where {T} = (@inline; a = Vector{T}(undef, 2); @inbounds (a[1] = x; a[2] = y); a)
getindex(::Type{T}, x, y, z) where {T} = (@inline; a = Vector{T}(undef, 3); @inbounds (a[1] = x; a[2] = y; a[3] = z); a)

function getindex(::Type{Any}, @nospecialize vals...)
a = Vector{Any}(undef, length(vals))
@inbounds for i = 1:length(vals)
Expand Down
3 changes: 2 additions & 1 deletion base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ const arch_march_isa_mapping = let
"armv8_0" => get_set("aarch64", "armv8.0-a"),
"armv8_1" => get_set("aarch64", "armv8.1-a"),
"armv8_2_crypto" => get_set("aarch64", "armv8.2-a+crypto"),
"armv8_4_crypto_sve" => get_set("aarch64", "armv8.4-a+crypto+sve"),
"a64fx" => get_set("aarch64", "a64fx"),
"apple_m1" => get_set("aarch64", "apple_m1"),
],
"powerpc64le" => [
"power8" => get_set("powerpc64le", "power8"),
Expand Down
13 changes: 11 additions & 2 deletions base/cmd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
setenv(cmd, env; dir=dir)
setenv(cmd::Cmd; dir=cmd.dir) = Cmd(cmd; dir=dir)

# split environment entry string into before and after first `=` (key and value)
function splitenv(e::String)
i = findnext('=', e, 2)
if i === nothing
throw(ArgumentError("malformed environment entry"))
end
e[1:prevind(e, i)], e[nextind(e, i):end]
end

"""
addenv(command::Cmd, env...; inherit::Bool = true)
Expand All @@ -282,7 +291,7 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
merge!(new_env, ENV)
end
else
for (k, v) in eachsplit.(cmd.env, "=")
for (k, v) in splitenv.(cmd.env)
new_env[string(k)::String] = string(v)::String
end
end
Expand All @@ -301,7 +310,7 @@ function addenv(cmd::Cmd, pairs::Pair{<:AbstractString}...; inherit::Bool = true
end

function addenv(cmd::Cmd, env::Vector{<:AbstractString}; inherit::Bool = true)
return addenv(cmd, Dict(k => v for (k, v) in eachsplit.(env, "=")); inherit)
return addenv(cmd, Dict(k => v for (k, v) in splitenv.(env)); inherit)
end

"""
Expand Down
Loading

0 comments on commit a10115e

Please sign in to comment.