Skip to content

Commit

Permalink
Fix BoundsError for regex deepcopy (#31309)
Browse files Browse the repository at this point in the history
  • Loading branch information
eulerkochy authored and StefanKarpinski committed Apr 2, 2019
1 parent 1e7242f commit 719c062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/deepcopy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ updated as appropriate before returning.
"""
deepcopy(x) = deepcopy_internal(x, IdDict())::typeof(x)

deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,UnionAll,Task},
deepcopy_internal(x::Union{Symbol,Core.MethodInstance,Method,GlobalRef,DataType,Union,UnionAll,Task,Regex},
stackdict::IdDict) = x
deepcopy_internal(x::Tuple, stackdict::IdDict) =
ntuple(i->deepcopy_internal(x[i], stackdict), length(x))
Expand Down
9 changes: 9 additions & 0 deletions test/copy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ end
@test c[1] === c[2]
end

@testset "issue #31309" begin
rgx1 = match(deepcopy(r""), "")
@test rgx1.regex == r""
@test rgx1.offset == 1
@test rgx1.match == ""
@test isempty(rgx1.offsets)
@test isempty(rgx1.captures)
end

# issue #30911
@test deepcopy(Array{Int,N} where N) == Array{Int,N} where N

Expand Down

0 comments on commit 719c062

Please sign in to comment.