PooledArrays.jl icon indicating copy to clipboard operation
PooledArrays.jl copied to clipboard

Fix copyto! with #undef

Open bkamins opened this issue 3 years ago • 3 comments

This fixes the following problem:

julia> x = PooledArray(["a", "b"])
2-element PooledVector{String, UInt32, Vector{UInt32}}:
 "a"
 "b"

julia> y = resize!(PooledArray(String[]), 2)
2-element PooledVector{String, UInt32, Vector{UInt32}}:
 #undef
 #undef

julia> copyto!(x, y)
ERROR: UndefRefError: access to undefined reference

Then maybe we also need to add in this PR

Base.copyto!(dest::PooledArrOrSub{T, N, R}, doffs::Union{Signed, Unsigned},
                      src::AbstractArray, soffs::Union{Signed, Unsigned},
                      n::Union{Signed, Unsigned}) where {T, N, R}

method depending on how https://github.com/JuliaLang/julia/issues/45125 is resolved.

CC @nalimilan

bkamins avatar Apr 30 '22 07:04 bkamins

Codecov Report

Merging #83 (ad1f384) into main (65e3316) will decrease coverage by 0.23%. The diff coverage is 66.66%.

@@            Coverage Diff             @@
##             main      #83      +/-   ##
==========================================
- Coverage   89.22%   88.98%   -0.24%     
==========================================
  Files           1        1              
  Lines         334      336       +2     
==========================================
+ Hits          298      299       +1     
- Misses         36       37       +1     
Impacted Files Coverage Δ
src/PooledArrays.jl 88.98% <66.66%> (-0.24%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 65e3316...ad1f384. Read the comment docs.

codecov[bot] avatar Apr 30 '22 07:04 codecov[bot]

Good catch, but apparently we need to wait for the result of the discussion at https://github.com/JuliaLang/julia/issues/45125 to know whether this behavior should be supported or not, right?

nalimilan avatar May 02 '22 20:05 nalimilan

Right.

My assumption is that in https://github.com/JuliaLang/julia/issues/45125 the conclusion will be: propagate #undef if it is possible, and throw an error otherwise.

bkamins avatar May 02 '22 21:05 bkamins