Skip to content

Commit a10115e

Browse files
authored
Merge pull request #44237 from JuliaLang/backports-release-1.8
release-1.8: Backports for julia 1.8-beta1
2 parents 7a1c20e + a274328 commit a10115e

44 files changed

Lines changed: 393 additions & 170 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/Base.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ include("weakkeydict.jl")
276276

277277
include("env.jl")
278278

279-
# BinaryPlatforms, used by Artifacts
280-
include("binaryplatforms.jl")
281-
282279
# functions defined in Random
283280
function rand end
284281
function randn end
@@ -336,6 +333,9 @@ using .Order
336333
include("sort.jl")
337334
using .Sort
338335

336+
# BinaryPlatforms, used by Artifacts. Needs `Sort`.
337+
include("binaryplatforms.jl")
338+
339339
# Fast math
340340
include("fastmath.jl")
341341
using .FastMath

base/abstractarray.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,13 +1712,15 @@ end
17121712
_cs(d, a, b) = (a == b ? a : throw(DimensionMismatch(
17131713
"mismatch in dimension $d (expected $a got $b)")))
17141714

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

17201722
function dims2cat(dims)
1721-
if any(dims .<= 0)
1723+
if any((0), dims)
17221724
throw(ArgumentError("All cat dimensions must be positive integers, but got $dims"))
17231725
end
17241726
ntuple(in(dims), maximum(dims))

base/abstractdict.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,10 @@ empty(a::AbstractDict) = empty(a, keytype(a), valtype(a))
189189
empty(a::AbstractDict, ::Type{V}) where {V} = empty(a, keytype(a), V) # Note: this is the form which makes sense for `Vector`.
190190

191191
copy(a::AbstractDict) = merge!(empty(a), a)
192-
copy!(dst::AbstractDict, src::AbstractDict) = merge!(empty!(dst), src)
192+
function copy!(dst::AbstractDict, src::AbstractDict)
193+
dst === src && return dst
194+
merge!(empty!(dst), src)
195+
end
193196

194197
"""
195198
merge!(d::AbstractDict, others::AbstractDict...)

base/abstractset.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
eltype(::Type{<:AbstractSet{T}}) where {T} = @isdefined(T) ? T : Any
44
sizehint!(s::AbstractSet, n) = nothing
55

6-
copy!(dst::AbstractSet, src::AbstractSet) = union!(empty!(dst), src)
6+
function copy!(dst::AbstractSet, src::AbstractSet)
7+
dst === src && return dst
8+
union!(empty!(dst), src)
9+
end
710

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

base/array.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -402,17 +402,20 @@ julia> getindex(Int8, 1, 2, 3)
402402
"""
403403
function getindex(::Type{T}, vals...) where T
404404
a = Vector{T}(undef, length(vals))
405-
@inbounds for i = 1:length(vals)
406-
a[i] = vals[i]
405+
if vals isa NTuple
406+
@inbounds for i in 1:length(vals)
407+
a[i] = vals[i]
408+
end
409+
else
410+
# use afoldl to avoid type instability inside loop
411+
afoldl(1, vals...) do i, v
412+
@inbounds a[i] = v
413+
return i + 1
414+
end
407415
end
408416
return a
409417
end
410418

411-
getindex(::Type{T}) where {T} = (@inline; Vector{T}())
412-
getindex(::Type{T}, x) where {T} = (@inline; a = Vector{T}(undef, 1); @inbounds a[1] = x; a)
413-
getindex(::Type{T}, x, y) where {T} = (@inline; a = Vector{T}(undef, 2); @inbounds (a[1] = x; a[2] = y); a)
414-
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)
415-
416419
function getindex(::Type{Any}, @nospecialize vals...)
417420
a = Vector{Any}(undef, length(vals))
418421
@inbounds for i = 1:length(vals)

base/binaryplatforms.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,8 @@ const arch_march_isa_mapping = let
608608
"armv8_0" => get_set("aarch64", "armv8.0-a"),
609609
"armv8_1" => get_set("aarch64", "armv8.1-a"),
610610
"armv8_2_crypto" => get_set("aarch64", "armv8.2-a+crypto"),
611-
"armv8_4_crypto_sve" => get_set("aarch64", "armv8.4-a+crypto+sve"),
611+
"a64fx" => get_set("aarch64", "a64fx"),
612+
"apple_m1" => get_set("aarch64", "apple_m1"),
612613
],
613614
"powerpc64le" => [
614615
"power8" => get_set("powerpc64le", "power8"),

base/cmd.jl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,15 @@ setenv(cmd::Cmd, env::Pair{<:AbstractString}...; dir=cmd.dir) =
262262
setenv(cmd, env; dir=dir)
263263
setenv(cmd::Cmd; dir=cmd.dir) = Cmd(cmd; dir=dir)
264264

265+
# split environment entry string into before and after first `=` (key and value)
266+
function splitenv(e::String)
267+
i = findnext('=', e, 2)
268+
if i === nothing
269+
throw(ArgumentError("malformed environment entry"))
270+
end
271+
e[1:prevind(e, i)], e[nextind(e, i):end]
272+
end
273+
265274
"""
266275
addenv(command::Cmd, env...; inherit::Bool = true)
267276
@@ -282,7 +291,7 @@ function addenv(cmd::Cmd, env::Dict; inherit::Bool = true)
282291
merge!(new_env, ENV)
283292
end
284293
else
285-
for (k, v) in eachsplit.(cmd.env, "=")
294+
for (k, v) in splitenv.(cmd.env)
286295
new_env[string(k)::String] = string(v)::String
287296
end
288297
end
@@ -301,7 +310,7 @@ function addenv(cmd::Cmd, pairs::Pair{<:AbstractString}...; inherit::Bool = true
301310
end
302311

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

307316
"""

0 commit comments

Comments
 (0)