JuliaIO / Tar.jl

TAR files: create, list, extract them in pure Julia
MIT License
80 stars 19 forks source link

Standardize string types in match call #136

Closed timholy closed 2 years ago

timholy commented 2 years ago

This will probably fail without the new convert methods in https://github.com/JuliaLang/julia/pull/44500, so wait until that is merged and we're ready to commit to Julia 1.9.

codecov[bot] commented 2 years ago

Codecov Report

Merging #136 (7eeb2dc) into master (b7f7418) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #136   +/-   ##
=======================================
  Coverage   97.29%   97.29%           
=======================================
  Files           4        4           
  Lines         775      775           
=======================================
  Hits          754      754           
  Misses         21       21           
Impacted Files Coverage Δ
src/extract.jl 98.11% <100.00%> (ø)

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 b7f7418...7eeb2dc. Read the comment docs.

KristofferC commented 2 years ago

CI still passed but not sure if that just means that this piece of code is untested.

timholy commented 2 years ago

I wondered about that too. https://app.codecov.io/gh/JuliaIO/Tar.jl/blob/master/src/extract.jl indicates it's tested. Presumably all AbstractStrings used in the tests are already String or SubString{String}:

julia> struct A end; struct B end;

julia> a = A()
A()

julia> convert(Union{A,B}, a)
A()

So it's only formally needed, to handle cases like

julia> struct C end

julia> Base.convert(::Type{A}, c::C) = A(); Base.convert(::Type{B}, c::C) = B();

julia> convert(Union{A, B}, C())
ERROR: MethodError: Cannot `convert` an object of type 
  C to an object of type 
  Union{A, B}
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:205
Stacktrace:
 [1] top-level scope
   @ REPL[33]:1
timholy commented 2 years ago

This should be safe to merge now, but no rush either.