Thread overview
[Issue 7285] New: Implicit fixed-size array cast
Jan 13, 2012
Kenji Hara
Jan 15, 2012
Walter Bright
January 13, 2012
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


--- Comment #0 from bearophile_hugs@eml.cc 2012-01-12 18:27:03 PST ---
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: -------
January 13, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7285


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

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


--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-12 22:29:16 PST ---
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: -------
January 15, 2012
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


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-01-15 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: -------