On Tue, 01 Mar 2011 18:11:00 -0500, bearophile <bearophileh...@lycos.com> wrote:

http://d.puremagic.com/issues/show_bug.cgi?id=5678

I think there is a general bug where any time the compiler uses an enum, it simply replaces the expression declared for the enum.

So basically

enum TRUE = new DElement(true);

void main()
{
   auto delem1 = TRUE;
   auto delem2 = TRUE;
   assert(delem1 is delem2); // fails
}

gets morphed into this:

void main()
{
   auto delem1 = new Delement(true);
   auto delem2 = new Delement(true);
   assert(delem1 is delem2); // fails
}

Obviously this works great when the enum is a value type or a string literal (which is created at compile time). However, it is not so great for things like AAs, array literals, objects, or structs.

I think there are a few of these bugs in bugzilla, and there should be at least a tracker, and if not, they should all be combined. This is a serious problem in D, and really creates havoc (both performance-wise and semantically). I don't anticipate there is an easy fix.

Essentially, I'd say enum is completely useless except for builtin types and strings.

-Steve

Reply via email to