Skip to content

Commit

Permalink
Merge pull request #3435 from 9rnsr/fix14685
Browse files Browse the repository at this point in the history
[REG2.067] Issue 14685 - Silent incorrect behavior with enforce and custom exception
  • Loading branch information
MartinNowak committed Jun 22, 2015
1 parent 53dbbaa commit 8c5bd63
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion std/exception.d
Expand Up @@ -394,7 +394,7 @@ private void bailOut(E : Throwable = Exception)(string file, size_t line, in cha
}
else
{
static assert("Expected this(string, string, size_t) or this(string, size_t)" ~
static assert(0, "Expected this(string, string, size_t) or this(string, size_t)" ~
" constructor for " ~ __traits(identifier, E));
}
}
Expand Down Expand Up @@ -509,6 +509,17 @@ deprecated unittest
enforce!(S, __FILE__, __LINE__)(s, "");
}

unittest
{
// Issue 14685

class E : Exception
{
this() { super("Not found"); }
}
static assert(!__traits(compiles, { enforce!E(false); }));
}

/++
If $(D !!value) is true, $(D value) is returned. Otherwise, $(D ex) is thrown.
Expand Down

0 comments on commit 8c5bd63

Please sign in to comment.