Skip to content

Commit

Permalink
Merge pull request #8100 from RazvanN7/Issue_18688
Browse files Browse the repository at this point in the history
Fix Issue 18688 - Constructors shouldn't have implicit super call if it throws
merged-on-behalf-of: Andrei Alexandrescu <andralex@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Mar 31, 2018
2 parents c83e4b5 + 978cb05 commit 830f9e0
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 @@
// 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);
}
}

0 comments on commit 830f9e0

Please sign in to comment.