Skip to content

Commit 2b7a874

Browse files
authored
Backports for julia 1.11.5 (#57714)
2 parents 8561cc3 + eccd25a commit 2b7a874

Some content is hidden

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

84 files changed

+1252
-925
lines changed

THIRDPARTY.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ for exceptions.
66
- [crc32c.c](https://stackoverflow.com/questions/17645167/implementing-sse-4-2s-crc32c-in-software) (CRC-32c checksum code by Mark Adler) [[ZLib](https://opensource.org/licenses/Zlib)].
77
- [LDC](https://github.com/ldc-developers/ldc/blob/master/LICENSE) (for ccall/cfunction ABI definitions) [BSD-3]. The portion of code that Julia uses from LDC is [BSD-3] licensed.
88
- [LLVM](https://releases.llvm.org/3.9.0/LICENSE.TXT) (for parts of src/disasm.cpp) [UIUC]
9-
- [MINGW](https://sourceforge.net/p/mingw/mingw-org-wsl/ci/legacy/tree/mingwrt/mingwex/dirname.c) (for dirname implementation on Windows) [MIT]
109
- [NetBSD](https://www.netbsd.org/about/redistribution.html) (for setjmp, longjmp, and strptime implementations on Windows) [BSD-3]
1110
- [Python](https://docs.python.org/3/license.html) (for strtod implementation on Windows) [PSF]
1211
- [FEMTOLISP](https://github.com/JeffBezanson/femtolisp) [BSD-3]

base/abstractarray.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3654,7 +3654,31 @@ function _keepat!(a::AbstractVector, m::AbstractVector{Bool})
36543654
deleteat!(a, j:lastindex(a))
36553655
end
36563656

3657-
## 1-d circshift ##
3657+
"""
3658+
circshift!(a::AbstractVector, shift::Integer)
3659+
3660+
Circularly shift, or rotate, the data in vector `a` by `shift` positions.
3661+
3662+
# Examples
3663+
3664+
```jldoctest
3665+
julia> circshift!([1, 2, 3, 4, 5], 2)
3666+
5-element Vector{Int64}:
3667+
4
3668+
5
3669+
1
3670+
2
3671+
3
3672+
3673+
julia> circshift!([1, 2, 3, 4, 5], -2)
3674+
5-element Vector{Int64}:
3675+
3
3676+
4
3677+
5
3678+
1
3679+
2
3680+
```
3681+
"""
36583682
function circshift!(a::AbstractVector, shift::Integer)
36593683
n = length(a)
36603684
n == 0 && return a

base/array.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,7 @@ function append! end
13201320

13211321
function append!(a::Vector{T}, items::Union{AbstractVector{<:T},Tuple}) where T
13221322
items isa Tuple && (items = map(x -> convert(T, x), items))
1323-
n = length(items)
1323+
n = Int(length(items))::Int
13241324
_growend!(a, n)
13251325
copyto!(a, length(a)-n+1, items, firstindex(items), n)
13261326
return a
@@ -1444,7 +1444,8 @@ julia> a[1:6]
14441444
1
14451445
```
14461446
"""
1447-
function resize!(a::Vector, nl::Integer)
1447+
function resize!(a::Vector, nl_::Integer)
1448+
nl = Int(nl_)::Int
14481449
l = length(a)
14491450
if nl > l
14501451
_growend!(a, nl-l)

base/cmd.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ julia> run(cm)
504504
Process(`echo 1`, ProcessExited(0))
505505
```
506506
"""
507-
macro cmd(str)
507+
macro cmd(str::String)
508508
cmd_ex = shell_parse(str, special=shell_special, filename=String(__source__.file))[1]
509509
return :(cmd_gen($(esc(cmd_ex))))
510510
end

base/compiler/effects.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ is_inaccessiblemem_or_argmemonly(effects::Effects) = effects.inaccessiblememonly
329329

330330
is_consistent_overlay(effects::Effects) = effects.nonoverlayed === CONSISTENT_OVERLAY
331331

332-
# (sync this with codegen.cpp and staticdata.c effects_foldable functions)
333332
function encode_effects(e::Effects)
334333
return ((e.consistent % UInt32) << 0) |
335334
((e.effect_free % UInt32) << 3) |

base/compiler/ssair/passes.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,10 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
14801480
used_ssas[x.id] -= 1
14811481
end
14821482
ir = complete(compact)
1483+
# remove any use that has been optimized away by the DCE
1484+
for (intermediaries, defuse) in values(defuses)
1485+
filter!(x -> ir[SSAValue(x.idx)][:stmt] !== nothing, defuse.uses)
1486+
end
14831487
sroa_mutables!(ir, defuses, used_ssas, lazydomtree, inlining)
14841488
return ir
14851489
else

base/exports.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ public
10951095
ImmutableDict,
10961096
Lockable,
10971097
OneTo,
1098+
Pairs,
10981099
LogRange,
10991100
UUID,
11001101

base/int.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ ERROR: LoadError: ArgumentError: invalid base 10 digit '.' in "123456789123.4"
647647
[...]
648648
```
649649
"""
650-
macro int128_str(s)
650+
macro int128_str(s::String)
651651
return parse(Int128, s)
652652
end
653653

@@ -667,7 +667,7 @@ ERROR: LoadError: ArgumentError: invalid base 10 digit '-' in "-123456789123"
667667
[...]
668668
```
669669
"""
670-
macro uint128_str(s)
670+
macro uint128_str(s::String)
671671
return parse(UInt128, s)
672672
end
673673

@@ -700,7 +700,7 @@ ERROR: ArgumentError: invalid number format _ for BigInt or BigFloat
700700
depends on the value of the precision at the point when the function is
701701
defined, **not** at the precision at the time when the function is called.
702702
"""
703-
macro big_str(s)
703+
macro big_str(s::String)
704704
message = "invalid number format $s for BigInt or BigFloat"
705705
throw_error = :(throw(ArgumentError($message)))
706706
if '_' in s

base/intfuncs.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ function nextpow(a::Real, x::Real)
526526
n = ceil(Integer,log(a, x))
527527
# round-off error of log can go either direction, so need some checks
528528
p = a^(n-1)
529-
x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base"))
529+
hastypemax(typeof(p)) && x > typemax(p) &&
530+
throw(DomainError(x,"argument is beyond the range of type of the base"))
530531
p >= x && return p
531532
wp = a^n
532533
wp > p || throw(OverflowError("result is beyond the range of type of the base"))
@@ -567,9 +568,10 @@ function prevpow(a::T, x::Real) where T <: Real
567568
n = floor(Integer,log(a, x))
568569
# round-off error of log can go either direction, so need some checks
569570
p = a^n
570-
x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base"))
571+
hastypemax(typeof(p)) && x > typemax(p) &&
572+
throw(DomainError(x,"argument is beyond the range of type of the base"))
571573
if a isa Integer
572-
wp, overflow = mul_with_overflow(a, p)
574+
wp, overflow = mul_with_overflow(promote(a, p)...)
573575
wp <= x && !overflow && return wp
574576
else
575577
wp = a^(n+1)
@@ -801,7 +803,7 @@ function append_c_digits(olength::Int, digits::Unsigned, buf, pos::Int)
801803
while i >= 2
802804
d, c = divrem(digits, 0x64)
803805
digits = oftype(digits, d)
804-
@inbounds d100 = _dec_d100[(c % Int) + 1]
806+
@inbounds d100 = _dec_d100[(c % Int)::Int + 1]
805807
@inbounds buf[pos + i - 2] = d100 % UInt8
806808
@inbounds buf[pos + i - 1] = (d100 >> 0x8) % UInt8
807809
i -= 2

base/iobuffer.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ function _copyline(out::IO, io::GenericIOBuffer; keep::Bool=false)
615615
data = view(io.data, io.ptr:io.size)
616616
# note: findfirst + copyto! is much faster than a single loop
617617
# except for nout ≲ 20. A single loop is 2x faster for nout=5.
618-
nout = nread = something(findfirst(==(0x0a), data), length(data))
618+
nout = nread = something(findfirst(==(0x0a), data), length(data))::Int
619619
if !keep && nout > 0 && data[nout] == 0x0a
620620
nout -= 1
621621
nout > 0 && data[nout] == 0x0d && (nout -= 1)

0 commit comments

Comments
 (0)