www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14685] New: Silent incorrect behavior with enforce and custom

https://issues.dlang.org/show_bug.cgi?id=14685

          Issue ID: 14685
           Summary: Silent incorrect behavior with enforce and custom
                    exception
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: thecybershadow gmail.com

Today, I wrote the following code:

/////////////// test.d //////////////
import std.exception;

class NotFoundException : Exception
{
    this() { super("Not found"); }
}

void main()
{
    enforce!NotFoundException(false);
}
/////////////////////////////////////

It compiles fine, but does not actually throw anything.

This seems to be a regression, as previously it did not compile.

Introduced in https://github.com/D-Programming-Language/phobos/pull/2288

--
Jun 11 2015