Overload === for custom type



I am trying to overload === on a custom type (as a workaround for https://discourse.julialang.org/t/surprising-struct-equality-test), but I get an error.

cannot add methods to a builtin function

Here is some code

struct T1 s::String end
Base.:(==)(x::T1, y::T1) = x.s == y.s
Base.:(===)(x::T1, y::T1) = x == s

Why is this forbidden?


According to the documentation, === and some others that are called builtins are singleton objects. I assume adding methods to those entry points would result in undefined behaviour or side effects as Julia itself relies on the correct implementation of such functions.