www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7285] New: Implicit fixed-size array cast

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7285

           Summary: Implicit fixed-size array cast
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This code compiles, because the [0,0] dynamic array literal casts implicitly to
int[2]:


int[2] foo() {
    return [0, 0]; // OK
}
void main() {}


And of course this too compiles:


int[2] bar() {
    int[2] ab;
    return (true) ? ab : ab; // OK
}
void main() {}



But currently this code doesn't compile:


int[2] spam() {
    int[2] ab;
    return (true) ? ab : [0, 0]; // Error
}
void main() {}


DMD 2.058head:
test.d(3): Error: cannot implicitly convert expression (cast(int[])ab) of type
int[] to int[2u]

I think this isn't good.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 12 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7285


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch



https://github.com/D-Programming-Language/dmd/pull/618

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 12 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7285


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



01:51:09 PST ---
https://github.com/D-Programming-Language/dmd/commit/61d4b884ca82933c759195492cb91086f8d2fba1

https://github.com/D-Programming-Language/dmd/commit/d1d5f8ef7c39d0a82aa55bde61152210aaf4f370

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