www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11381] New: warn/error when static if else ladder has no matching block (or misses "else")

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11381

           Summary: warn/error when static if else ladder has no matching
                    block (or misses "else")
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code dawg.eu



static if (T.sizeof == 4) { /*A*/ }
else static if (T.sizeof == 8) { /*B*/ }
else static if (T.sizeof == 12) { /*C*/ }

version (Windows) {}
else version (linux) {}
else version (OSX) {}

static if (something) {}
else version (foo) {}
else static if (somethingelse) {}

----

When such a construct is detected and none of the conditional blocks is matched
the compiler should warn/error about an unhandled case.
We could also try to make the declaration of such a ladder without an
else-clause a warning/error. This would require an explicit "else {}" to
achieve the current behavior and avoids inadvertently missing else clauses
similar to how non-final switch statements require a default label.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 29 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11381


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



08:29:58 PDT ---
A somewhat related ER:

http://d.puremagic.com/issues/show_bug.cgi?id=8433

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 30 2013