www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19549] New: -check=in=off doesn't work

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

          Issue ID: 19549
           Summary: -check=in=off doesn't work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: greensunny12 gmail.com

// REQUIRED_ARGS: -check=in=off -check=invariant=off
// PERMUTE_ARGS:
class C
{
    int foo(int a)
    in { assert(a != 0); } // skipped
    out(res) { assert(res != 0, "out"); } // triggered
    body
    {
        return a;
    }

    invariant // skipped
    {
        assert(false);
    }
}

void main()
{
    import core.exception : AssertError;

    auto c = new C;
    bool catched;
    try
        c.foo(0);
    catch (AssertError e)
    {
        assert(e.msg == "out");
        catched = e.msg == "out";
    }

    if (!catched)
        assert(0);
}

--
Jan 04 2019