[Issue 9051] New: [CTFE] Working with non-trivial immutable globals?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 20 12:50:43 PST 2012


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

           Summary: [CTFE] Working with non-trivial immutable globals?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-11-20 12:50:42 PST ---
I'm wondering if this is supposed to work. By all means I don't see why it has
to try this(this) in this case (and moreover fail).

struct Set{
    uint[] arr;
    this(this){  } //comment out to make it compile
}

pure auto getMeASet(uint[] arr)
{
    return Set(arr);
}

immutable set = getMeASet([1,2,3,4]);

pure auto getSecond(in Set set)
{
    return set.arr[1];
}

pragma(msg, getSecond(set));

And the diagnostic spits all kinds of nonsense:

D:\D\ctfe_glob.d(20): Error: variable ctfe_glob.__cpcttmp6 of type struct
const(Set) uses this(this), which is not allowed in static initialization
D:\D\ctfe_glob.d(20):        while evaluating pragma(msg, getSecond((const
const(Set) __cpcttmp6 = Set([1u, 2u, 3u, 4u]);
 , __cpcttmp6)))

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


More information about the Digitalmars-d-bugs mailing list