Skip to content

Commit

Permalink
Merge pull request #6431 from LemonBoy/b16346
Browse files Browse the repository at this point in the history
Fix issue 16346 - Use the correct type when constructing an enum
  • Loading branch information
MartinNowak committed Jan 13, 2017
2 parents c1d138c + 82f8a0a commit 5607986
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/expression.d
Expand Up @@ -9866,6 +9866,14 @@ extern (C++) final class CallExp : UnaExp
else if (e1.op == TOKtype && t1.isscalar())
{
Expression e;

// Make sure to use the the enum type itself rather than its
// base type (see bugzilla 16346)
if (e1.type.ty == Tenum)
{
t1 = e1.type;
}

if (!arguments || arguments.dim == 0)
{
e = t1.defaultInitLiteral(loc);
Expand Down
3 changes: 3 additions & 0 deletions test/compilable/b16346.d
@@ -0,0 +1,3 @@
enum A { B }
static assert(is(typeof(A.B) == A));
static assert(is(typeof(A(A.B)) == A));

0 comments on commit 5607986

Please sign in to comment.