diff --git a/src/Groups/GAPGroups.jl b/src/Groups/GAPGroups.jl index b71cbaf8509..68152aa1ddf 100644 --- a/src/Groups/GAPGroups.jl +++ b/src/Groups/GAPGroups.jl @@ -372,9 +372,26 @@ end Base.:*(x::GAPGroupElem, y::GAPGroupElem) = _prod(x, y) -==(x::GAPGroup, y::GAPGroup) = GapObj(x) == GapObj(y) +function ==(x::GAPGroup, y::GAPGroup) + _check_compatible(x, y) + return GapObj(x) == GapObj(y) +end + +# For two `BasicGAPGroupElem`s, +# we allow the question for equality if their parents fit together +# in the sense of `_check_compatible`, +# and compare the `GapObj`s if this is the case. +function ==(x::BasicGAPGroupElem, y::BasicGAPGroupElem) + _check_compatible(parent(x), parent(y)) + return GapObj(x) == GapObj(y) +end -==(x::BasicGAPGroupElem, y::BasicGAPGroupElem ) = GapObj(x) == GapObj(y) +# For two `GAPGroupElem`s, +# if no specialized method is applicable then no `==` comparison is allowed. +function ==(x::GAPGroupElem, y::GAPGroupElem) + _check_compatible(parent(x), parent(y); error = false) || throw(ArgumentError("parents of x and y are not compatible")) + throw(ArgumentError("== is not implemented for the given types")) +end """ one(G::GAPGroup) -> elem_type(G) diff --git a/test/Groups/conformance.jl b/test/Groups/conformance.jl index e92c09bf253..dbbc4ceed9f 100644 --- a/test/Groups/conformance.jl +++ b/test/Groups/conformance.jl @@ -60,6 +60,10 @@ include(joinpath(dirname(pathof(AbstractAlgebra)), "..", "test", "Groups-conform @test g>h || g==h || g