[Issue 6783] New: Implicit cast to immutable from pure function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 7 15:35:31 PDT 2011


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

           Summary: Implicit cast to immutable from pure function
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-10-07 15:34:46 PDT ---
This program compiles with no errors (DMD 2.056head):


immutable(int[]) foo(in int[2] x) pure {
    return new int[1];
}
void main() {}



While this doesn't compile:


immutable(int[]) foo(in int[] x) pure {
    return new int[1];
}
void main() {}


It gives:
test.d(2): Error: cannot implicitly convert expression (new int[](1u)) of type
int[] to immutable(int[])

I am not sure, but I think the second program too is correct.

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