Skip to content

Commit

Permalink
Fix Issue 18688 - Constructors shouldn't have implicit super call if …
Browse files Browse the repository at this point in the history
…it throws
  • Loading branch information
RazvanN7 committed Mar 29, 2018
1 parent 69ece8c commit ccdde63
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dmd/expressionsem.d
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
43 changes: 43 additions & 0 deletions test/compilable/test18688.d
@@ -0,0 +1,43 @@
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);
}
}

void main() {}

0 comments on commit ccdde63

Please sign in to comment.