Thread overview
[Issue 20653] Short-circuiting boolean logic not working
Mar 10, 2020
Ketmar Dark
Mar 10, 2020
Manu
Mar 10, 2020
Dennis
Mar 10, 2020
Manu
Mar 18, 2020
Dlang Bot
Mar 19, 2020
Dlang Bot
March 10, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

Ketmar Dark <ketmar@ketmar.no-ip.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ketmar@ketmar.no-ip.org

--- Comment #1 from Ketmar Dark <ketmar@ketmar.no-ip.org> ---
it never worked with static ifs. i was pretty sure that it was By Design, but i cannot remember if i really read that somewhere in the specs, or simply made it out.

--
March 10, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

--- Comment #2 from Manu <turkeyman@gmail.com> ---
My work-around is to use a `static if()` to split the expression across
multiple lines.
It's not a good workaround; it's lame and unnecessary.

--
March 10, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

Dennis <dkorpel@live.nl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dkorpel@live.nl

--- Comment #3 from Dennis <dkorpel@live.nl> ---
(In reply to Ketmar Dark from comment #1)
> it never worked with static ifs. i was pretty sure that it was By Design, but i cannot remember if i really read that somewhere in the specs, or simply made it out.

Short circuiting actually works in certain static conditions:

```
static if (false && bogusName) {}
static assert(true || bogusName);
void foo(T)() if (true ? true : bogusName) {};
alias x = foo!int;
```

This is implemented in staticcond.d, function `evalStaticCondition`:

> Semantically analyze and then evaluate a static condition at compile time. This is special because short circuit operators &&, || and ?: at the top level are not semantically analyzed if the result of the expression is not necessary.

That function is not used to evaluate enums however.

--
March 10, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

--- Comment #4 from Manu <turkeyman@gmail.com> ---
Right. That's why there is a bug report :)

--
March 18, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@benjones updated dlang/dmd pull request #10939 "fix issue 20653 .  Short circuit manifest constant evaluation" fixing this issue:

- fix issue 20653 .  Short circuit manifest constant evaluation

https://github.com/dlang/dmd/pull/10939

--
March 19, 2020
https://issues.dlang.org/show_bug.cgi?id=20653

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #10939 "fix issue 20653 .  Short circuit manifest constant evaluation" was merged into master:

- 73fab586f68d28b448f3712a28edc024862015b2 by Ben Jones:
  fix issue 20653 -- apply short circuit evaluation for manifest constants

https://github.com/dlang/dmd/pull/10939

--