diff --git a/NEWS.md b/NEWS.md index a8efb91bf9..a6f3d88395 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,14 @@ v0.14.17 - Fixed some type instabilities PR [#2004](https://github.com/CliMA/ClimaCore.jl/pull/2004) - More fixes to higher resolution column cases for the GPU [#1854](https://github.com/CliMA/ClimaCore.jl/pull/1854) +### ![][badge-🐛bugfix] Fix equality for `FieldVector`s with different type + +Due to a bug, `==` was not recursively checking `FieldVector`s with different +types, which resulted in false positives. This is now fixed and `FieldVector`s +with different types are always considered different. + +PR [#2021](https://github.com/CliMA/ClimaCore.jl/pull/2021). + v0.14.16 ------- diff --git a/src/Fields/fieldvector.jl b/src/Fields/fieldvector.jl index 1dc3ee30f8..520a86349e 100644 --- a/src/Fields/fieldvector.jl +++ b/src/Fields/fieldvector.jl @@ -487,10 +487,18 @@ end Recursively compare given fieldvectors via `==`. Returns `true` if `x == y` recursively. + +FieldVectors with different types are considered different. """ rcompare(x::T, y::T) where {T <: Union{FieldVector, NamedTuple}} = _rcompare(true, x, y) -# Define == to call rcompare for two fieldvectors of the same -# exact type. -Base.:(==)(x::T, y::T) where {T <: FieldVector} = rcompare(x, y) +rcompare(x::T, y::T) where {T <: FieldVector} = _rcompare(true, x, y) + +rcompare(x::T, y::T) where {T <: NamedTuple} = _rcompare(true, x, y) + +# FieldVectors with different types are always different +rcompare(x::FieldVector, y::FieldVector) = false + +# Define == to call rcompare for two fieldvectors +Base.:(==)(x::FieldVector, y::FieldVector) = rcompare(x, y)