Permalink
Browse files

Merge pull request #1464 from 9rnsr/fix9293

Issue 9293 - enum struct with StructInitializer reports weird error
  • Loading branch information...
2 parents 7686d93 + 895f191 commit 7f9d6c8aa9d7c7fc2d798c5e75696ef3a815192c @WalterBright WalterBright committed Jan 13, 2013
Showing with 30 additions and 0 deletions.
  1. +4 −0 src/declaration.c
  2. +26 −0 test/runnable/structlit.d
View
@@ -2013,6 +2013,10 @@ Expression *VarDeclaration::getConstInitializer()
ExpInitializer *ei = getExpInitializer();
if (ei)
return ei->exp;
+ else if (init)
+ {
+ return init->toExpression();
+ }
}
return NULL;
View
@@ -590,6 +590,31 @@ void test9116()
}
/********************************************/
+// 9293
+
+void test9293()
+{
+ static struct A
+ {
+ // enum A zero = A(); // This works as expected
+ enum A zero = {}; // Note the difference here
+
+ int opCmp(const ref A a) const
+ {
+ assert(0);
+ }
+
+ int opCmp(const A a) const
+ {
+ return 0;
+ }
+ }
+
+ A a;
+ auto b = a >= A.zero; // Error: A() is not an lvalue
+}
+
+/********************************************/
int main()
{
@@ -614,6 +639,7 @@ int main()
test7929();
test7021();
test9116();
+ test9293();
printf("Success\n");
return 0;

0 comments on commit 7f9d6c8

Please sign in to comment.