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 */ } ----
@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
The second case causes an error as well in DMD 2.088.0-beta.1. This is a partial regression now.
@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
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
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 <thewilsonator@users.noreply.github.com> https://github.com/dlang/dmd/pull/10348