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

Have copy(ci::CodeInfo) also copy ci.edges. #33523

Merged

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Oct 10, 2019

Before this commit, it was a shallow-copy, so the array was shared between the original ci and the copy.

CC: @vchuravy

Came up in JuliaLabs/Cassette.jl#148

Before this commit, it was a shallow-copy, so the array was shared
between the orginal ci and the copy.
@JeffBezanson JeffBezanson merged commit 2b1fc4c into JuliaLang:master Oct 11, 2019
cnew.ssaflags = copy(cnew.ssaflags)
ssavaluetypes = cnew.ssavaluetypes
cnew.ssaflags = copy(cnew.ssaflags)
cnew.edges = cnew.edges === nothing ? nothing : copy(cnew.edges)
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeffBezanson: this is why it's sometimes handy to have copy methods for immutables—you want to copy something in case it's mutable, but maybe it isn't.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general you need x === nothing ? nothing : f(x); this is just a case of that. This argument clearly wouldn't apply to functions other than copy; I suspect copy just feels like a more reasonable function to implement since it's so close to the identity function.

@NHDaly NHDaly deleted the nhdaly--copy-CodeInfo-copy-edges branch October 11, 2019 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants