Thread overview
[Issue 7007] New: [] should have a type of its own
Nov 25, 2011
timon.gehr@gmx.ch
Nov 26, 2011
Kenji Hara
Nov 26, 2011
timon.gehr@gmx.ch
November 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7007

           Summary: [] should have a type of its own
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2011-11-25 13:20:47 PST ---
Now that null has an own type (issue 5416), typeof([]) == void[] is
inconsistent.

Consider:

void foo(int[] x){}

void bar(T)(T x){foo(x);}


void main(){
    foo(null); // ok
    foo([]);   // ok
    bar(null); // ok!
    bar([]);   // fail
}

This example should compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7007



--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> 2011-11-26 00:43:39 PST ---
There are some implementation issues.

If you name an unspecified element type as 'Nothing',

auto a  = [];         // Nothing[]
auto b1 = [[]];       // Nothing[][]
auto b2 = [[], null]; // Nothing[][], but its runtime is different from b1

int[][] na1 = b1;     // may need runtime allocation and conversion int[][] na2 = b2;     // may need runtime allocation and conversion

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7007



--- Comment #2 from timon.gehr@gmx.ch 2011-11-26 07:25:17 PST ---
Nothing[][] is not a subtype of int[][]. The assignments should not even compile.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7007


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #3 from bearophile_hugs@eml.cc 2012-08-26 04:38:24 PDT ---
See also Issue 8589

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