[Issue 13185] New: Detect precondition violations at compile time when possible

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Jul 22 06:26:25 PDT 2014


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

          Issue ID: 13185
           Summary: Detect precondition violations at compile time when
                    possible
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: contracts
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: yebblies at gmail.com
          Reporter: yebblies at gmail.com

In many cases, the compiler can easily detect that a function call cannot
possibly pass the precondition.

int divide(int x, int y)
in
{
    assert(y != 0);
}
body
{
    return x / y;
}

void main()
{
    func(3);
    divide(9, 0);
}

In these cases we can produce an error at compile time.

--


More information about the Digitalmars-d-bugs mailing list