From 51efeed5b6d52f9e8ee9000f9b9a6142630da978 Mon Sep 17 00:00:00 2001 From: "Bowen S. Zhu" Date: Mon, 4 Nov 2024 16:21:41 -0500 Subject: [PATCH] Fix: Consider metadata in `BasicSymbolic` `isequal` --- src/types.jl | 1 + test/basics.jl | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/types.jl b/src/types.jl index 683f58d44..6872b2dea 100644 --- a/src/types.jl +++ b/src/types.jl @@ -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) diff --git a/test/basics.jl b/test/basics.jl index 1402f9aca..7d731daf9 100644 --- a/test/basics.jl +++ b/test/basics.jl @@ -336,6 +336,12 @@ 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(a1, a2) + @test !isequal(a1, a3) end @testset "subtyping" begin