www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18115] New: [REG2.078-b1] case where && is not shortcut

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

          Issue ID: 18115
           Summary: [REG2.078-b1] case where && is not shortcut anymore in
                    CTFE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: b2.temp gmx.com

The following code does not compile anymore, starting from 2.078 beta1:

```
module test;

class A23456{}

string foo()
{
    string result;
    mixin("alias m = " ~ __MODULE__ ~ ";");
    foreach (member; __traits(allMembers, m))
    {
        if (member.length > 5 && member[$-6..$] == "A23456")
            result ~= member ~ " ";
    }
    return result;
}

enum e = foo();
```

A workaround is to turn the `if` into a `static if` however this is a
regression.

--
Dec 23 2017