www.digitalmars.com         C & C++   DMDScript  

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

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: bearophile_hugs eml.cc



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: -------
Mar 19 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7737


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |9665



This is non-const object initialization problem.

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