[Issue 23998] New: @mustuse should require opCast(T:bool) is checked

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Jun 18 10:29:16 UTC 2023


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

          Issue ID: 23998
           Summary: @mustuse should require opCast(T:bool) is checked
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: alphaglosined at gmail.com

This is something I've run into while using @mustuse.

The struct could very well be used, without any error being checked.

While I'm not sure opCast(T:bool) should always be used for this purpose, it
should be possible to require the compiler to error if it does not occur
(although it would be nice not to do this when it comes from
opApply/opApplyReverse.

The reason I have used the opCast is because of its integration into if
statements which makes it quite nice to use, when it isn't crashing the program
(due to error not being checked).

Without this, an ``alias this`` to a method would in theory be enough to keep
the compiler happy even if it's null.

--


More information about the Digitalmars-d-bugs mailing list