diff --git a/src/dmd/expressionsem.d b/src/dmd/expressionsem.d index efb1546db83f..4540d45b5115 100644 --- a/src/dmd/expressionsem.d +++ b/src/dmd/expressionsem.d @@ -3264,7 +3264,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return setError(); } - if (!sc.intypeof && !(sc.callSuper & CSX.halt)) + if (!sc.intypeof) { if (sc.noctor || sc.callSuper & CSX.label) exp.error("constructor calls not allowed in loops or after labels"); @@ -3301,7 +3301,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor return setError(); } - if (!sc.intypeof && !(sc.callSuper & CSX.halt)) + if (!sc.intypeof) { if (sc.noctor || sc.callSuper & CSX.label) exp.error("constructor calls not allowed in loops or after labels"); diff --git a/test/compilable/test18688.d b/test/compilable/test18688.d new file mode 100644 index 000000000000..e61a7ac466f8 --- /dev/null +++ b/test/compilable/test18688.d @@ -0,0 +1,43 @@ +// https://issues.dlang.org/show_bug.cgi?id=18688 + +class A +{ + this(int x){} + @disable this(); +} + +class B: A +{ + this(int x) + { + super(x); + } + + this(string b) + { + switch(b) + { + case "a":break; + default: assert(false); + } + this(1); + } +} + +class C: A +{ + this(int x) + { + super(x); + } + + this(string b) + { + switch(b) + { + case "a":break; + default: assert(false); + } + super(1); + } +}