Skip to content

Commit

Permalink
fix Issue 14685 - Silent incorrect behavior with enforce and custom e…
Browse files Browse the repository at this point in the history
…xception
  • Loading branch information
9rnsr committed Jun 22, 2015
1 parent a170c46 commit 4f2e16e
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 4f2e16e

Please sign in to comment.