On Sunday, 18 June 2017 at 11:11:59 UTC, Johan Engelen wrote:
On Sunday, 18 June 2017 at 09:56:50 UTC, Steven Schveighoffer
wrote:
On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote:
Reviving this thread to see whether anything has changed on
the topic.
If Timon gets static for ea
ggers that "statement is not reachable" if at least
one of U1,U2,... = T is bool, will not occur if you instead use
`static foreach (i, U; T)`.
On Sunday, 18 June 2017 at 09:56:50 UTC, Steven Schveighoffer
wrote:
On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote:
Reviving this thread to see whether anything has changed on
the topic.
If Timon gets static for each into the language, it can look a
little better.
Can you h
On Sunday, 18 June 2017 at 09:28:57 UTC, Johan Engelen wrote:
Reviving this thread to see whether anything has changed on the
topic.
If Timon gets static for each into the language, it can look a
little better.
-Steve
Reviving this thread to see whether anything has changed on the
topic.
I now have this monster:
```
struct FMT {
// has immutable members. FMT cannot be assigned to.
}
FMT monsterThatCompilerAccepts(T)(){
alias TP = Tuple!(__traits(getAttributes, T));
foreach(i, att; TP){
stat
On Friday, 1 April 2016 at 01:21:32 UTC, Walter Bright wrote:
On 3/16/2016 4:18 AM, Johan Engelen wrote:
I've found discussions, but not an actual "recommended"
solution for the
problem of "statement is not reachable" warnings in templates
with early
returns
On Friday, 1 April 2016 at 01:21:32 UTC, Walter Bright wrote:
On 3/16/2016 4:18 AM, Johan Engelen wrote:
I've found discussions, but not an actual "recommended"
solution for the
problem of "statement is not reachable" warnings in templates
with early
returns
On 3/16/2016 4:18 AM, Johan Engelen wrote:
I've found discussions, but not an actual "recommended" solution for the
problem of "statement is not reachable" warnings in templates with early
returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
Hi all,
I've found discussions, but not an actual "recommended"
solution for the problem of "statement is not reachable" warnings
in templates with early returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
static if (is(U == bool)) {
On 3/16/16 7:18 AM, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended" solution for
the problem of "statement is not reachable" warnings in templates with
early returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
well. This will
hopefully be fixed sooner or later:
https://github.com/D-Programming-Language/dmd/pull/1913
https://github.com/D-Programming-Language/dmd/pull/5229
The only future-proof way to fix the "statement is not reachable"
warning, is to guard the potentially unreachab
On Thursday, 17 March 2016 at 17:12:07 UTC, Steven Schveighoffer
wrote:
Yes. I agree. The way I look at it is that the code *is*
reached in some cases, so it should compile (and just remove
that section in that instance).
IMO any time a template value is used for branching, it should
turn tha
On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended"
solution for the problem of "statement is not reachable"
warnings in templates with early returns, e.g.:
```
bool nobool(T...)
On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote:
import std.meta;
template isBool(U)() = is(U == bool);
static if (!allSatisfy!(isBool, T)) {
return true; // no longer emits a warning
}
Something like this should work.
Thanks, but:
On Wednesday, 16 March 2016 at 11:18:36 UTC,
On 17/03/16 5:05 AM, Johan Engelen wrote:
On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole wrote:
Change those static if's to just plain old ifs.
But then this wouldn't compile, would it?
```
static if(__traits(compiles, __traits(getMember, a, "b"))) {
return a.b;
}
```
(real
On Wednesday, 16 March 2016 at 17:08:20 UTC, Johan Engelen wrote:
On Wednesday, 16 March 2016 at 11:47:35 UTC, QAston wrote:
import std.meta;
template isBool(U)() = is(U == bool);
static if (!allSatisfy!(isBool, T)) {
return true; // no longer emits a warning
}
Something like this should
On Wednesday, 16 March 2016 at 17:34:13 UTC, Steven Schveighoffer
wrote:
On 3/16/16 7:18 AM, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended"
solution for
the problem of "statement is not reachable" warnings in
templates
sooner or later:
https://github.com/D-Programming-Language/dmd/pull/1913
https://github.com/D-Programming-Language/dmd/pull/5229
The only future-proof way to fix the "statement is not reachable"
warning, is to guard the potentially unreachable code with a
`static if` whose pred
On 16/03/16 11:18 PM, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended" solution for
the problem of "statement is not reachable" warnings in templates with
early returns, e.g.:
```
bool nobool(T...)() {
foreach (i, U; T) {
On Wednesday, 16 March 2016 at 11:22:02 UTC, rikki cattermole
wrote:
Change those static if's to just plain old ifs.
But then this wouldn't compile, would it?
```
static if(__traits(compiles, __traits(getMember, a, "b"))) {
return a.b;
}
```
(real code, I am not making this up)
Imagine tho
On Wednesday, 16 March 2016 at 11:18:36 UTC, Johan Engelen wrote:
Hi all,
I've found discussions, but not an actual "recommended"
solution for the problem of "statement is not reachable"
warnings in templates with early returns...
"statement is not reachable
On Wednesday, 2 March 2016 at 09:37:03 UTC, Johan Engelen wrote:
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote:
Thanks, fixing this single issue solved the compiler crash too.
Did the compiler crash? Or just exit?
(a crash would still be a bug)
Crashed, just like in the case of Edw
On Wednesday, 2 March 2016 at 07:42:09 UTC, Tamas wrote:
Thanks, fixing this single issue solved the compiler crash too.
Did the compiler crash? Or just exit?
(a crash would still be a bug)
Thanks, fixing this single issue solved the compiler crash too.
Thanks also for the tip using hasUDA! Works nicely!
On 01.03.2016 22:30, Tamas wrote:
struct Tag {}
template isTagged(S) {
enum bool isTagged =
delegate() {
foreach(attr; __traits(getAttributes, S)) {
static if (is(attr == Tag)) {
return true;
}
}
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote:
foreach(attr; __traits(getAttributes, S)) {
static if (is(attr == Tag)) {
return true;
}
}
return false;
}();
}
void main() {
static @Tag struct MyStru
On Tuesday, 1 March 2016 at 21:30:44 UTC, Tamas wrote:
My d code doesn't compile using ldc2 1.0.0-alpha or anything
above DMD v2.068.0
Using these compilers I get a lot of "Warning: statement is not
reachable". Then the both compiler crashes.
ldc2 -w reach.d
dmd -w r
My d code doesn't compile using ldc2 1.0.0-alpha or anything
above DMD v2.068.0
Using these compilers I get a lot of "Warning: statement is not
reachable". Then the both compiler crashes.
I minimized the code to get the same warning, although the
compilers do not crash thi
On Thu, Mar 5, 2009 at 10:45 AM, Qian Xu wrote:
> Hi Jarrett,
>
> but I need an exception here. This is an unexpected case. I want no instance
> to be create in this case.
By the time the constructor runs, an instance has already been
created. But if you throw an exception in the ctor, it's impo
Qian Xu wrote:
Jarrett Billingsley wrote:
On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu
wrote:
this(char[] s, int flag) {
if (flag == 1)
{
this(1);
return;
}
else if (flag == 2)
{
this("hello");
return;
}
throw new Exception("unhandled case");
this(0); // fake
This line is unreachable. The 'thro
Jarrett Billingsley wrote:
> On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu
> wrote:
>
>> this(char[] s, int flag) {
>> if (flag == 1)
>> {
>> this(1);
>> return;
>> }
>> else if (flag == 2)
>> {
>> this("hello");
>> return;
>> }
>> throw new Exception("unhandled case");
>> this(0); // fake
>
> This l
On Thu, Mar 5, 2009 at 3:17 AM, Qian Xu wrote:
> this(char[] s, int flag) {
> if (flag == 1)
> {
> this(1);
> return;
> }
> else if (flag == 2)
> {
> this("hello");
> return;
> }
> throw new Exception("unhandled case");
> this(0); // fake
This line is
--------------
The warning is: "statement is not reachable"
If I use switch-case-statment, I can see even an error message:
"constructor calls not allowed in loops or after labels"
So, is my design incorrect, or is the compiler too strict?
--Qian Xu
33 matches
Mail list logo