Skip to content

Commit 8cab0d2

Browse files
JeffBezansonKristofferC
authored andcommitted
fix some 1.5 compatibility issues (#35965)
- restore some `copyto!` methods that Knet assumed existed - allow `findfirst` to work on InfiniteArrays again - allow constructing a LineNumberNode from a String (cherry picked from commit 853fe04)
1 parent af5d5a6 commit 8cab0d2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

base/array.jl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,15 @@ Copy `N` elements from collection `src` starting at offset `so`, to array `dest`
320320
offset `do`. Return `dest`.
321321
"""
322322
function copyto!(dest::Array, doffs::Integer, src::Array, soffs::Integer, n::Integer)
323+
return _copyto_impl!(dest, doffs, src, soffs, n)
324+
end
325+
326+
# this is only needed to avoid possible ambiguities with methods added in some packages
327+
function copyto!(dest::Array{T}, doffs::Integer, src::Array{T}, soffs::Integer, n::Integer) where T
328+
return _copyto_impl!(dest, doffs, src, soffs, n)
329+
end
330+
331+
function _copyto_impl!(dest::Array, doffs::Integer, src::Array, soffs::Integer, n::Integer)
323332
n == 0 && return dest
324333
n > 0 || _throw_argerror()
325334
if soffs < 1 || doffs < 1 || soffs+n-1 > length(src) || doffs+n-1 > length(dest)
@@ -339,6 +348,9 @@ end
339348

340349
copyto!(dest::Array, src::Array) = copyto!(dest, 1, src, 1, length(src))
341350

351+
# also to avoid ambiguities in packages
352+
copyto!(dest::Array{T}, src::Array{T}) where {T} = copyto!(dest, 1, src, 1, length(src))
353+
342354
# N.B: The generic definition in multidimensional.jl covers, this, this is just here
343355
# for bootstrapping purposes.
344356
function fill!(dest::Array{T}, x) where T
@@ -1762,8 +1774,8 @@ CartesianIndex(1, 1)
17621774
```
17631775
"""
17641776
function findnext(testf::Function, A, start)
1777+
i = oftype(first(keys(A)), start)
17651778
l = last(keys(A))
1766-
i = oftype(l, start)
17671779
i > l && return nothing
17681780
while true
17691781
testf(A[i]) && return i

base/boot.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ _new(:QuoteNode, :Any)
370370
_new(:SSAValue, :Int)
371371
eval(Core, :(LineNumberNode(l::Int) = $(Expr(:new, :LineNumberNode, :l, nothing))))
372372
eval(Core, :(LineNumberNode(l::Int, @nospecialize(f)) = $(Expr(:new, :LineNumberNode, :l, :f))))
373+
LineNumberNode(l::Int, f::String) = LineNumberNode(l, Symbol(f))
373374
eval(Core, :(GlobalRef(m::Module, s::Symbol) = $(Expr(:new, :GlobalRef, :m, :s))))
374375
eval(Core, :(SlotNumber(n::Int) = $(Expr(:new, :SlotNumber, :n))))
375376
eval(Core, :(TypedSlot(n::Int, @nospecialize(t)) = $(Expr(:new, :TypedSlot, :n, :t))))

0 commit comments

Comments
 (0)