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


Don <clugd...@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
            Summary|[CTFE] Working with         |Passing an immutable global
                   |non-trivial immutable       |with post-blit to a CTFE
                   |globals?                    |function


--- Comment #1 from Don <clugd...@yahoo.com.au> 2012-11-21 02:13:04 PST ---
The error message is not coming from CTFE. Here's a simple case from a comment
in the compiler source code (declaration.c):

/* The problem is the following code:
*  struct CopyTest {
*     double x;
*     this(double a) { x = a * 10.0;}
*     this(this) { x += 2.0; }
*  }
*  const CopyTest z = CopyTest(5.3);  // ok
*  const CopyTest w = z;              // not ok, postblit not run
*  static assert(w.x == 55.0);
* because the postblit doesn't get run on the initialization of w.
*/

I think that if we didn't call this(this), wrong code would result.
There is at least a diagnostic bug here - if it must behave this way, the code
that creates the comma expression should be issuing the error.

Interestingly, if you move it inside a function, the result is different:

void foo()
{
   pragma(msg, getSecond(set));
}

qqq.d(19): Error: static variable set cannot be referenced at compile time
qqq.d(19):        called from here: __cpcttmp6.__cpctor(set)
qqq.d(19):        called from here: getSecond((const const(Set) __cpcttmp6 =
__cpcttmp6.__cpctor(set);
 , __cpcttmp6))

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to