Should compile:
----
struct S
{
bool opCast(T : bool)() { return true; }
}
void main()
{
static if (S.init) {} /* Error: expression (S).init of type S does not have a boolean value */
static if (!!S.init) {} /* no error */
if (S.init) {} /* no error */
}
----
Comment #1 by dlang-bot — 2019-07-28T22:42:29Z
@dkorpel created dlang/dmd pull request #10237 "Fix issue 20021 - static if doesn't evaluate opCast(bool)" fixing this issue:
- fix issue 20021 - static if doesn't evaluate opCast(bool)
https://github.com/dlang/dmd/pull/10237
Comment #2 by elpenguino+D — 2019-08-20T02:21:18Z
The second case causes an error as well in DMD 2.088.0-beta.1. This is a partial regression now.
Comment #3 by dlang-bot — 2019-08-20T09:14:52Z
@aG0aep6G created dlang/dmd pull request #10324 "fix issue 20021 - static if doesn't evaluate opCast(bool) " fixing this issue:
- fix issue 20021 - static if doesn't evaluate opCast(bool)
https://github.com/dlang/dmd/pull/10324
Comment #4 by dlang-bot — 2019-08-20T10:53:14Z
dlang/dmd pull request #10324 "fix issue 20021 - static if doesn't evaluate opCast(bool) " was merged into stable:
- 98cab64efd160365bde1bcc1b7230cc92e58ced1 by dkorpel:
fix issue 20021 - static if doesn't evaluate opCast(bool)
https://github.com/dlang/dmd/pull/10324
Comment #5 by dlang-bot — 2019-08-25T21:26:23Z
dlang/dmd pull request #10348 "Merge remote-tracking branch 'upstream/stable' into merge_stable" was merged into master:
- 421e9ce137c6aff941ebde92863c53292226a0b3 by aG0aep6G:
fix issue 20021 - static if doesn't evaluate opCast(bool) (#10324)
fix issue 20021 - static if doesn't evaluate opCast(bool)
merged-on-behalf-of: Nicholas Wilson <[email protected]>
https://github.com/dlang/dmd/pull/10348