https://issues.dlang.org/show_bug.cgi?id=3926

RazvanN <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |WONTFIX
           Severity|normal                      |enhancement

--- Comment #1 from RazvanN <[email protected]> ---
This is an enhancement request as the spec clearly states that for boolean
operations only structs will implicitly call opCast:
https://dlang.org/spec/operatoroverloading.html#boolean_operators (point 3).
Indeed, if a struct is transitioned to a class this is problematic, however,
other problems might appear also (for example, equality comparisons).
Therefore, I don't think this is a good argument for implementing this and most
likely this might silently change the behavior of a lot of code.

One solution would be to have a third party tool (like D-Scanner) implement a
check for class instances that are used in if conditions and also define an
opCast. A warning could be issued then.

--

Reply via email to