Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn/error when static if else ladder has no matching block (or misses "else") #17620

Open
dlangBugzillaToGithub opened this issue Oct 29, 2013 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Martin Nowak (@MartinNowak) reported this on 2013-10-29T19:57:05Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=11381

CC List

Description

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.
@dlangBugzillaToGithub
Copy link
Author

andrej.mitrovich (@AndrejMitrovic) commented on 2013-10-30T08:29:58Z

A somewhat related ER:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant