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

Instance of mutable struct does not compare equal to deepcopied instance #33359

Closed
KristofferC opened this issue Sep 22, 2019 · 1 comment
Closed
Labels
kind:regression Regression in behavior compared to a previous version

Comments

@KristofferC
Copy link
Sponsor Member

KristofferC commented Sep 22, 2019

Edit: Reduced to this:

1.3:

julia> mutable struct F end; f = F(); f == deepcopy(f)
false

1.2:

julia> mutable struct F end; f = F(); f == deepcopy(f)
true

Looking at the test regression for 1.3-RC3 vs 1.2 in Alpine.jl I find that on 1.3:

4|julia> m.minlp_solver == empty_solver
false

4|julia> m.minlp_solver
Alpine.UnsetSolver()

4|julia> empty_solver
Alpine.UnsetSolver()

while on 1.2

1|julia> m.minlp_solver == empty_solver
true

1|julia> m.minlp_solver
Alpine.UnsetSolver()

1|julia> empty_solver
Alpine.UnsetSolver()

UnsetSolver is a singleton mutable struct defined here:

https://github.com/lanl-ansi/Alpine.jl/blob/b0d97aadd402a26fdb8c833871d0350fdc2c6378/src/solver.jl#L318-L321

and the same constant is assigned to the field minlp_solver field:

https://github.com/lanl-ansi/Alpine.jl/blob/b0d97aadd402a26fdb8c833871d0350fdc2c6378/src/solver.jl#L400-L402

Making it non-mutable works around the problem.

@KristofferC KristofferC added the kind:regression Regression in behavior compared to a previous version label Sep 22, 2019
@KristofferC KristofferC removed the kind:regression Regression in behavior compared to a previous version label Sep 22, 2019
@KristofferC KristofferC changed the title Singleton values (of mutable struct) are sometimes not equal Instance of mutable struct does not compare equal to same instance Sep 22, 2019
@KristofferC KristofferC added the kind:regression Regression in behavior compared to a previous version label Sep 22, 2019
@KristofferC KristofferC changed the title Instance of mutable struct does not compare equal to same instance Instance of mutable struct does not compare equal to deepcopied instance Sep 22, 2019
@KristofferC
Copy link
Sponsor Member Author

Actually, this is just a bugfix I guess... #17149, #25854 etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

1 participant