www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15166] New: [Ref 2.069-devel] spurious statement not

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

          Issue ID: 15166
           Summary: [Ref 2.069-devel] spurious statement not reachable
                    warning in static foreach loop
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
template Group(T...)
{
    alias expand = T;
}

private bool compare(alias Group1, alias Group2)()
{
    foreach (index, element; Group1.expand)
    {
        static if (!is(Group1.expand[index] == Group2.expand[index]))
            return false;
    }
    return true;
}

unittest
{
    alias a = Group!(int, double), b = Group!(double, int);
    static assert (!compare!(a, b));
}
CODE

dmd -c -w -unittest bug
----
DMD v2.069-devel-6279af3 DEBUG
bug.d(13): Warning: statement is not reachable
----
This is similar to issue 14835, but now the warning is also emitted with static
foreach loops.

--
Oct 05 2015