From acf75c71da5f2a6e57c6ac71dda55bee4f3eb041 Mon Sep 17 00:00:00 2001 From: Andreas Evensen <58504549+thesombady@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:31:47 +0100 Subject: [PATCH] docs: document the return type restrictions for operator overloading (#20529) --- doc/docs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/docs.md b/doc/docs.md index 7edd93b3a4..bfc754b9dd 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -6191,6 +6191,8 @@ To improve safety and maintainability, operator overloading is limited. - When overriding `<` and `==`, the return type must be strictly `bool`. - Both arguments must have the same type (just like with all operators in V). +- Overloaded operators have to return the same type as the argument + (the exceptions are `<` and `==`). #### Other restrictions