Skip to content

Commit

Permalink
Merge pull request #6571 from yazd/issue16083
Browse files Browse the repository at this point in the history
Fix issue 16083 - AliasSeq loses type of enums that have the same value
  • Loading branch information
WalterBright committed Mar 9, 2017
2 parents c87ed3d + 71c5839 commit 154681d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/ddmd/dtemplate.d
Expand Up @@ -260,7 +260,12 @@ private bool match(RootObject o1, RootObject o2)
printf("\te1 = %s '%s' %s\n", e1.type.toChars(), Token.toChars(e1.op), e1.toChars());
printf("\te2 = %s '%s' %s\n", e2.type.toChars(), Token.toChars(e2.op), e2.toChars());
}
if (!e1.equals(e2))

// two expressions can be equal although they do not have the same
// type; that happens when they have the same value. So check type
// as well as expression equality to ensure templates are properly
// matched.
if (!e1.type.equals(e2.type) || !e1.equals(e2))
goto Lnomatch;

goto Lmatch;
Expand Down
15 changes: 15 additions & 0 deletions test/compilable/test16083.d
@@ -0,0 +1,15 @@
template Alias(Stuff...)
{
alias Alias = Stuff;
}

enum A { a = 0 }
enum B { b = 0 }

enum C { c = "abc" }
enum D { d = "abc" }

static assert(is(typeof(Alias!(A.a)[0]) == A));
static assert(is(typeof(Alias!(B.b)[0]) == B));
static assert(is(typeof(Alias!(C.c)[0]) == C));
static assert(is(typeof(Alias!(D.d)[0]) == D));

0 comments on commit 154681d

Please sign in to comment.