www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16340] New: case where version(unittest) results in an

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

          Issue ID: 16340
           Summary: case where version(unittest) results in an invalid
                    warning about a dangling else
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: issues.dlang jmdavisProg.com

This is a reduced version of some code that I've been working on:


void main()
{
}

version(unittest) template symsToStrs(fields...)
{
    static if(fields.length == 0)
        enum symsToStrs = ["hello"];
    else
        enum symsToStrs = ["world"];
}


Note that if you compile it with warnings enabled, you get something like

q.d(9): Warning: else is dangling, add { } after condition at q.d(5)

However, if you remove the version(unittest) from in front of the template,
then the warning goes away. Whether the code is compiled with -unittest doesn't
matter. But regardless, there is no dangling else here. So, the warning is
incorrect.


this problem anymore, so it doesn't look like this is a regression of that bug,
though its cause may be similar.

--
Jul 30 2016