diff --git a/src/dmd/semantic3.d b/src/dmd/semantic3.d index 320d275b37d1..9bdf87e260e1 100644 --- a/src/dmd/semantic3.d +++ b/src/dmd/semantic3.d @@ -529,7 +529,7 @@ private extern(C++) final class Semantic3Visitor : Visitor if (auto s = funcdecl.fensure.isScopeStatement()) fensure_endlin = s.endloc.linnum; - if ((needEnsure && global.params.useOut) || fpostinv) + if ((needEnsure && global.params.useOut == CHECKENABLE.on) || fpostinv) { funcdecl.returnLabel = new LabelDsymbol(Id.returnLabel); } @@ -903,7 +903,7 @@ private extern(C++) final class Semantic3Visitor : Visitor sc2 = sc2.pop(); - if (!global.params.useIn) + if (global.params.useIn == CHECKENABLE.off) freq = null; } if (fens) @@ -937,7 +937,7 @@ private extern(C++) final class Semantic3Visitor : Visitor sc2 = sc2.pop(); - if (!global.params.useOut) + if (global.params.useOut == CHECKENABLE.off) fens = null; } if (funcdecl.fbody && funcdecl.fbody.isErrorStatement()) diff --git a/test/runnable/test_dip1006.d b/test/runnable/test_dip1006.d new file mode 100644 index 000000000000..d8a8b4bccc93 --- /dev/null +++ b/test/runnable/test_dip1006.d @@ -0,0 +1,38 @@ +// REQUIRED_ARGS: -check=in=off -check=out=off -check=invariant=off +// PERMUTE_ARGS: +class C +{ + int foo(int a) + in { assert(a != 0); } // skipped + out(res) { assert(res != 0); } // skipped + body + { + return a; + } + + invariant // skipped + { + assert(false); + } + + void bar(int a) + { + assert(a != 0); // triggered + } +} + +void main() +{ + import core.exception : AssertError; + + auto c = new C; + c.foo(0); + + bool catched; + try + c.bar(0); + catch (AssertError e) + catched = true; + if (!catched) + assert(0); +} diff --git a/test/runnable/test_dip1006b.d b/test/runnable/test_dip1006b.d new file mode 100644 index 000000000000..e64efbacac4d --- /dev/null +++ b/test/runnable/test_dip1006b.d @@ -0,0 +1,35 @@ +// 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); +}