[Issue 7737] New: std.typecons.Typedef problem with immutable initialized in static this()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 19 17:22:29 PDT 2012


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

           Summary: std.typecons.Typedef problem with immutable
                    initialized in static this()
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2012-03-19 17:22:46 PDT ---
I don't know if it's possible to fix this just changing Phobos. Maybe more is
needed.

Tests performed with DMD 2.059head:

This compiles:

alias int[] Arr;
immutable Arr a;
pure nothrow static this() {
    a = [1, 2, 3];
}
void main() {}



This compiles (with -d):

typedef int[] Arr;
immutable Arr a;
pure nothrow static this() {
    a = [1, 2, 3];
}
void main() {}



This compiles:

import std.typecons: Typedef;
alias Typedef!(int[]) Arr;
Arr a;
nothrow static this() {
    a = [1, 2, 3];
}
void main() {}



But this doesn't compile:

import std.typecons: Typedef;
alias Typedef!(int[]) Arr;
immutable Arr a;
pure nothrow static this() {
    a = [1, 2, 3];
}
void main() {}


It gives:

test.d(5): Error: template
std.typecons.Typedef!(int[],null).Typedef.Proxy!(Typedef_payload).opAssign(this
X,V) does not match any function template declaration
test.d(5): Error: template
std.typecons.Typedef!(int[],null).Typedef.Proxy!(Typedef_payload).opAssign(this
X,V) cannot deduce template function from argument types !()(int[])

-- 
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