[Issue 16201] When all paths inside a static if return/throw, the portion after static if should be as if "else" were used
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jun 24 11:33:00 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=16201
--- Comment #6 from Mathias Lang <mathias.lang at sociomantic.com> ---
Should it only work on `static if` level ?
E.g. if you have:
```
void fun(T)(T obj)
{
throw new Exception("No gun");
obj.gun;
}
```
Should it have the same behaviour ?
If not, that should be fixable at the same time as issue 14835 (and has the
same prerequisites).
However, it's not trivial to implement either, e.g. consider the following
code:
```
void fun(T)(T obj)
{
static if (!hasMember(T, "gun")) {
if (bar)
goto Label;
throw new Exception("No gun");
}
// This would not be compiled in after the change, resulting in an
// "undefined label 'Label'" error.
Label: myFunc();
}
```
--
More information about the Digitalmars-d-bugs
mailing list