Skip to content

Commit 100601e

Browse files
committed
transfer id counter to copies of state
1 parent 364592d commit 100601e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/code.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ end
786786

787787
CSEState() = CSEState(Union{Assignment, DestructuredArgs}[], IdDict(), Ref(1))
788788

789-
Base.copy(x::CSEState) = CSEState(copy(x.sorted_exprs), copy(x.visited), Ref(x.varid[]))
789+
# the copy still references the same `varid` Ref to work in nested scopes
790+
Base.copy(x::CSEState) = CSEState(copy(x.sorted_exprs), copy(x.visited), x.varid)
790791

791792
"""
792793
$(TYPEDSIGNATURES)

0 commit comments

Comments
 (0)