Skip to content

Commit a2b4dcf

Browse files
committed
Add break_sharing to copy
1 parent 4180759 commit a2b4dcf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/base.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,9 @@ We check against the map before making a new copy; otherwise
394394
we can simply reference the existing copy.
395395
[Thanks to Ted Hopp.](https://stackoverflow.com/questions/49285475/how-to-copy-a-full-non-binary-tree-including-loops)
396396
"""
397-
function copy_node(tree::N; break_sharing=Val(false)) where {T,N<:AbstractExpressionNode{T}}
397+
function copy_node(
398+
tree::N; break_sharing::Val=Val(false)
399+
) where {T,N<:AbstractExpressionNode{T}}
398400
return tree_mapreduce(
399401
t -> if t.constant
400402
constructorof(N)(; val=t.val::T)
@@ -409,7 +411,9 @@ function copy_node(tree::N; break_sharing=Val(false)) where {T,N<:AbstractExpres
409411
)
410412
end
411413

412-
copy(tree::AbstractExpressionNode) = copy_node(tree)
414+
function copy(tree::AbstractExpressionNode; break_sharing::Val=Val(false))
415+
return copy_node(tree; break_sharing)
416+
end
413417

414418
"""
415419
convert(::Type{AbstractExpressionNode{T1}}, n::AbstractExpressionNode{T2}) where {T1,T2}

0 commit comments

Comments
 (0)