Skip to content

Commit

Permalink
Merge pull request #8144 from WalterBright/fix18737
Browse files Browse the repository at this point in the history
fix Issue 18737 - An assert(0) should be a leaf in constructor flow a…
merged-on-behalf-of: Razvan Nitu <RazvanN7@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Apr 10, 2018
2 parents 9398ee9 + 88f48d6 commit e84c0a0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/dmd/expressionsem.d
Expand Up @@ -3278,7 +3278,7 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor
}
}

if (!sc.intypeof /*&& !(sc.ctorflow.callSuper & CSX.halt)*/)
if (!sc.intypeof && !(sc.ctorflow.callSuper & CSX.halt))
{
if (sc.inLoop || sc.ctorflow.callSuper & CSX.label)
exp.error("constructor calls not allowed in loops or after labels");
Expand Down
43 changes: 0 additions & 43 deletions test/compilable/test18688.d

This file was deleted.

32 changes: 32 additions & 0 deletions test/compilable/test18737.d
@@ -0,0 +1,32 @@
/* REQUIRED_ARGS:
* PERMUTE_ARGS:
*/

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

struct S
{
this(char);

this(int j)
{
this('a');
assert(0);
this('b');
}

this(long j)
{
if (j)
{
this('c');
assert(0);
}
else if (j + 1)
{
this('d');
return;
}
this('e');
}
}

0 comments on commit e84c0a0

Please sign in to comment.