Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 18688 - Constructors shouldn't have implicit super call if it throws #8100

Merged
merged 1 commit into from Mar 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add:

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

{
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);
}
}