Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BoundsError for regex deepcopy #31309

Merged
merged 2 commits into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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