Skip to content

Commit

Permalink
Merge pull request #8077 from WalterBright/fix17942
Browse files Browse the repository at this point in the history
fix Issue 17942 - Enums are evaluated differently in global scope
merged-on-behalf-of: Iain Buclaw <ibuclaw@gdcproject.org>
  • Loading branch information
dlang-bot committed Mar 25, 2018
2 parents b9a190b + 8c28783 commit cee0643
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/dmd/semantic2.d
Expand Up @@ -237,6 +237,13 @@ private extern(C++) final class Semantic2Visitor : Visitor

//printf("VarDeclaration::semantic2('%s')\n", toChars());

if (vd.aliassym) // if it's a tuple
{
vd.aliassym.accept(this);
vd.semanticRun = PASS.semantic2done;
return;
}

if (vd._init && !vd.toParent().isFuncDeclaration())
{
vd.inuse++;
Expand Down Expand Up @@ -563,7 +570,7 @@ private extern(C++) final class Semantic2Visitor : Visitor

override void visit(AggregateDeclaration ad)
{
//printf("AggregateDeclaration::semantic2(%s) type = %s, errors = %d\n", toChars(), type.toChars(), errors);
//printf("AggregateDeclaration::semantic2(%s) type = %s, errors = %d\n", ad.toChars(), ad.type.toChars(), ad.errors);
if (!ad.members)
return;

Expand Down
15 changes: 15 additions & 0 deletions test/compilable/test17942.d
@@ -0,0 +1,15 @@
// https://issues.dlang.org/show_bug.cgi?id=17942

alias AliasSeq(TList...) = TList;

void test()
{
enum A = AliasSeq!(1);
static assert(A[0] == 1);
static assert(B[0] == 2);
}

enum B = AliasSeq!(2);

enum C = AliasSeq!();

0 comments on commit cee0643

Please sign in to comment.