Overloading comparative operator in Delphi mode should allow result type other than Boolean
Original Reporter info from Mantis: PeterJanRoes
-
Reporter name: Peter-Jan Roes
Original Reporter info from Mantis: PeterJanRoes
- Reporter name: Peter-Jan Roes
Description:
When in Delphi mode it should be possible to declare an overloaded comparative operator that returns something other than a Boolean. Currently the compiler emits an error when a type other than Boolean is declared as a result type. This is incompatible with Delphi and is very easy to solve by just skipping the check that emits the error in Delphi mode.
Please note that the Delphi Help does show overload declarations for comparative operators returning Boolean. However, the Delphi compiler does not force the result type to be Boolean.
Finally, I do not really understand why the check for Boolean results would be desirable in general: it just limits your power of expression and you do not seem to gain anything in return. Therefore, one might want to consider removing the check altogether, and not just for Delphi mode.
Steps to reproduce:
See attached .dpr for an example that tries to build an expression tree using operator overloading. Here the desired result of the GreaterThan operator would not be Boolean, but a TExpressionBuilder instead.
Mantis conversion info:
- Mantis ID: 25004
- Version: 2.6.3
- Fixed in version: 3.0.0
- Fixed in revision: 25494 (#99dadf29)
- Monitored by: » PaulIsh (Paul Ishenin), » PeterJanRoes (Peter-Jan Roes)