From 12503d908853e65732995351ee9579cfb1384fa0 Mon Sep 17 00:00:00 2001 From: RazvanN7 Date: Mon, 26 Mar 2018 18:43:14 +0300 Subject: [PATCH] Fix Issue 18578 - First enum value assigned 0 instead of EnumBaseType.init --- src/dmd/dsymbolsem.d | 3 +-- test/compilable/test18578.d | 5 +++++ test/fail_compilation/diag7477.d | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 test/compilable/test18578.d diff --git a/src/dmd/dsymbolsem.d b/src/dmd/dsymbolsem.d index 2db047e9ca5d..869d4e59051f 100644 --- a/src/dmd/dsymbolsem.d +++ b/src/dmd/dsymbolsem.d @@ -2232,8 +2232,7 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor if (!em.ed.isAnonymous()) em.ed.memtype = t; } - Expression e = new IntegerExp(em.loc, 0, Type.tint32); - e = e.implicitCastTo(sc, t); + Expression e = new IntegerExp(em.loc, 0, t); e = e.ctfeInterpret(); // save origValue for better json output diff --git a/test/compilable/test18578.d b/test/compilable/test18578.d new file mode 100644 index 000000000000..d75a063d09e1 --- /dev/null +++ b/test/compilable/test18578.d @@ -0,0 +1,5 @@ +enum Foo { foo1 } +enum Bar : Foo { bar } + +void main() +{} diff --git a/test/fail_compilation/diag7477.d b/test/fail_compilation/diag7477.d index 1c971847bc86..b82b33de9463 100644 --- a/test/fail_compilation/diag7477.d +++ b/test/fail_compilation/diag7477.d @@ -1,8 +1,8 @@ /* TEST_OUTPUT: --- -fail_compilation/diag7477.d(13): Error: cannot implicitly convert expression `0` of type `int` to `Foo` -fail_compilation/diag7477.d(20): Error: cannot implicitly convert expression `0` of type `int` to `string` +fail_compilation/diag7477.d(13): Error: integral constant must be scalar type, not `Foo` +fail_compilation/diag7477.d(20): Error: integral constant must be scalar type, not `string` --- */