Skip to content

Commit

Permalink
Fix: Consider metadata in BasicSymbolic isequal
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenszhu committed Nov 4, 2024
1 parent f9b0ade commit 1bce8ae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ function Base.isequal(a::BasicSymbolic{T}, b::BasicSymbolic{S}) where {T,S}
E === exprtype(b) || return false

T === S || return false
isequal(metadata(a), metadata(b)) || return false
return _isequal(a, b, E)::Bool
end
function _isequal(a, b, E)
Expand Down
7 changes: 7 additions & 0 deletions test/basics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ end

@test !isequal(a, missing)
@test !isequal(missing, b)

a1 = setmetadata(a, Ctx1, "meta_1")
a2 = setmetadata(a, Ctx1, "meta_1")
a3 = setmetadata(a, Ctx2, "meta_2")
@test !isequal(a, a1)
@test isequal(a1, a2)
@test !isequal(a1, a3)
end

@testset "subtyping" begin
Expand Down

0 comments on commit 1bce8ae

Please sign in to comment.