Bug 9293 – enum struct with StructInitializer reports weird error

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-10T22:03:00Z
Last change time
2013-01-13T02:45:54Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg

Comments

Comment #0 by k.hara.pg — 2013-01-10T22:03:36Z
Spin-off from bug 9218. This code should run without assertion, but the compilation fails with weird error message. 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; } } void main() { A a; auto b = a >= A.zero; // Error: A() is not an lvalue }
Comment #1 by k.hara.pg — 2013-01-10T22:14:41Z
Comment #2 by github-bugzilla — 2013-01-13T00:41:12Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/895f19174dffc9088c0516f2c8cc47f8f4c589fa fix Issue 9293 - enum struct with StructInitializer reports weird error `VarDeclaration::getConstInitializer` should return an actual expression, even if init is not an `ExpInitializer`. https://github.com/D-Programming-Language/dmd/commit/7f9d6c8aa9d7c7fc2d798c5e75696ef3a815192c Merge pull request #1464 from 9rnsr/fix9293 Issue 9293 - enum struct with StructInitializer reports weird error