Skip to content

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

Closed
@KristofferC

Description

@KristofferC

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    regressionRegression in behavior compared to a previous version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions