June 18, 2023 [Issue 23998] New: @mustuse should require opCast(T:bool) is checked | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: alphaglosined@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. -- |
Copyright © 1999-2021 by the D Language Foundation