www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7007] New: [] should have a type of its own

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



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: -------
Nov 25 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7007




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: -------
Nov 26 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7007




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: -------
Nov 26 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7007


bearophile_hugs eml.cc changed:

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



See also Issue 8589

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