Don <> changed:

           What    |Removed                     |Added
           Keywords|rejects-valid               |patch, wrong-code

--- Comment #5 from Don <> 2010-04-11 14:51:25 PDT ---
Actually this is a rare case where the ICE bug is the same as the others.
I don't think it has anything to do with constructor varargs, actually.
It involves using a struct constructor to perform type inference of a member of
that struct.

Here's an example of a situation where the current behaviour leads to wrong

struct Vec {
   int w;
   this(int x) { w = 2; }

   enum KK = Vec(100);
   enum Vec KK2 = Vec(100);

static assert(Vec.KK == Vec.KK2);
// Error: static assert  ((Vec(100)) == (Vec(2))) is false

PATCH. Issue an error message in these potentially recursive situations.
Although in this specific case, it could be made to compile by running semantic
on the constructors first, that won't work in general (the constructor may make
use of the enum, for example).
I've tested this on the DMD test suite, and it passes.

expression.c CallExp::semantic(), line 6790.

                /* Constructors return a pointer to the instance
                e = new PtrExp(loc, e);
                e = e->semantic(sc);
                return e;
+            // Check for a forward reference to a struct constructor.
+            else if (arguments && arguments->dim && !ad->ctor && ad->sizeok !=
+            {
+                // The semantic pass of the struct isn't yet complete.
+                // Check for attempt to use a constructor.
+                Dsymbol *ctor = ad->search(0, Id::ctor, 0);
+                if (ctor)
+                {
+                    error("Forward reference to struct constructor");
+                    return new ErrorExp();
+                }
+            }

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to